C#在TLP中的面板上绘图

时间:2016-02-02 20:33:43

标签: c#

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);
 }

这项工作在表格上。但是对于自动调整按钮,标签等项目的大小,我必须使用TablePanelLayout,并且绘制它只适用于添加到表单中的construtor

panel1.Paint+=new PaintEventHandler(panel1_draw);

然后用这个方法绘图

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);
}

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

0 个答案:

没有答案