我定义了一个新类,在类中重写了onPaint函数,类的大致结构如下:
class PlainForm : Form
{
protected override void OnPaint(PaintEventArgs e)
{
...........
}
}
在Form1(主窗体)中有一个textBox,需要怎么做才能在重写的onPaint函数里读取textBox的text值?
class PlainForm : Form
{
protected override void OnPaint(PaintEventArgs e)
{
...........
}
}
在Form1(主窗体)中有一个textBox,需要怎么做才能在重写的onPaint函数里读取textBox的text值?
但是你为什么要在OnPaint里面得到这个值呢 能不能说下你的目的?
如果改为base.TextBox1.Text会出现未定义的错误,有什么办法可以解决吗?
然后
Form1 form1 = new Form1();
form1.textBox1.Text = "";
这样。最好是通过给Form1增加一个public的方法或者属性来得到textBox1的值,使用MVC的设计。