I have this:
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();
}
}
I’m getting an index exception when I try this. If I debug it I see that InitializeComponent() doesn’t run..
Code in my main app:
var frmUpload = new FrmUpload(FormTextUpload);
if (frmUpload.ShowDialog() != DialogResult.OK) return;
Instead of calling the base class constructor:
call your own parameterless contructor: