【发布时间】:2018-07-01 01:01:13
【问题描述】:
我已经制作了这个包含按钮的用户控件
using System.Windows.Forms;
namespace test2
{
public partial class testme : UserControl
{
public testme()
{
InitializeComponent();
}
public testme(string x)
{
button1.Text = x;
}
}
}
然后我正在尝试使用构造函数更改用户控件中的按钮
using System;
using System.Windows.Forms;
namespace test2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
testme v = new testme("New Text");
}
}
}
但是当我在运行时单击 button1 时,我收到此错误消息 对象引用未设置为对象的实例
【问题讨论】:
标签: c# .net winforms user-controls