我有这个:
public partial class FrmUpload : Form
{
public FrmUpload()
{
InitializeComponent();
}
public FrmUpload(Dictionary<string, string> ft) : base()
{
foreach (KeyValuePair<string, string> ctrl in ft)
{
Controls.Find(ctrl.Key, true)[0].Text = ctrl.Value;
}
}
private void BtnCancelClick(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
private void BtnExitClick(object sender, EventArgs e)
{
DialogResult = DialogResult.OK;
Close();
}
}
尝试此操作时出现索引异常。如果我调试它,我会看到 InitializeComponent() 没有运行..
我的主应用程序中的代码:
var frmUpload = new FrmUpload(FormTextUpload);
if (frmUpload.ShowDialog() != DialogResult.OK) return;