TLP面板上的C#图纸

TLP面板上的C#图纸,c#,C#,这项工作是按形式进行的。但对于按钮、标签等自动调整大小的项目,我必须使用TablePanelLayout,在其上绘图只能在表单中添加到Constructor private void panel1_Paint(object sender, PaintEventArgs e) { Graphics graphicObj; graphicObj = this.CreateGraphics(); Pen myPen = new Pen(System.Drawing.Color.Black

这项工作是按形式进行的。但对于按钮、标签等自动调整大小的项目,我必须使用TablePanelLayout,在其上绘图只能在表单中添加到Constructor

private void panel1_Paint(object sender, PaintEventArgs e)
 {
  Graphics graphicObj;
  graphicObj = this.CreateGraphics();
  Pen myPen = new Pen(System.Drawing.Color.Black, 2);

  graphicObj.DrawEllipse(myPen, 200, 200, 200, 200);
 }
然后用这种方法作图

panel1.Paint+=new PaintEventHandler(panel1_draw);

问题是为什么/我应该掌握什么主题才能了解它。

为什么/我应该掌握什么主题才能了解它?
你在问什么?有些东西不起作用了吗?永远不要使用CreateGraphics,它只是一个临时画布。我想您需要了解Control.DoubleBuffered属性。当双缓冲打开时,像在第一个代码片段中那样将像素飞溅到窗口上无法工作。就像按钮和标签控件一样。一毫秒后,当后台缓冲区快速显示到屏幕上时,这些像素再次消失。使用CreateGraphics()进行绘制只有在不介意丢失像素并以非常高的速率绘制时才是正确的。就像在游戏中一样。
private void panel1_Paint(object sender, PaintEventArgs e)
{
    var g = e.Graphics;
    Pen myp = new Pen(System.Drawing.Color.Red, 4);
    Font fy = new Font("Helvetica", 10, FontStyle.Bold);
    Brush br = new SolidBrush(System.Drawing.Color.Red);
    g.DrawString(textBox1.Text, fy, br, 0,0);
}