0
在我的項目「teacher_gui_windows_form」中,我嘗試將我從工具箱中創建的userControl拖動到表單「teacher_gui」,但它給了我錯誤: 「無法創建組件」 StudentControl',錯誤信息如下:System.MissingMethodException找不到類型'teacher_gui_windows_form.StudentControl'的構造函數。「無法在Windows窗體中創建組件userControl:
但我確實有一個StudentControl構造函數。 的StudentControl類使用另一種形式,這裏是它的類代碼:
public partial class StudentControl : UserControl
{
const int Num = 10;
Image image;
string message;
public StudentForm studentForm = null;
public StudentControl(Image image, string Ip, int index)
{
InitializeComponent();
this.image = image;
pictureBoxImage.Image = image;
labelIp.Text = Ip;
Location = new Point(index % Num * (Width + 5), index/Num * (Height + 5));
}
public void ChangeImage(Image image)
{
pictureBoxImage.Image = image;
}
private void StudentControl_Click(object sender, EventArgs e)
{
studentForm = new StudentForm(pictureBoxImage.Image);
studentForm.ShowDialog();
}
private void pictureBoxImage_Click(object sender, EventArgs e)
{
studentForm = new StudentForm(pictureBoxImage.Image);
studentForm.ShowDialog();
}
private void labelIp_Click(object sender, EventArgs e)
{
studentForm = new StudentForm(pictureBoxImage.Image);
studentForm.ShowDialog();
}
private void seizeToolStripMenuItem_Click(object sender, EventArgs e)
{
}
private void sendMessageToolStripMenuItem_Click(object sender, EventArgs e)
{
}
}
有誰知道爲什麼會出現這種情況? 謝謝!
你不能指望你的鼠標咳嗽那個構造函數的有效參數。你必須提供一個不帶參數的。或者編寫代碼而不是使用鼠標。 –