D
David
In C#, I am creating a combobox and loading the data in via. the
DataSource
method.
Eg:
this.comboBox.DataSource = a1;
this.comboBox.DisplayMember = "name";
this.comboBox.ValueMember = "key";
I also need to set the displayed item in the combobox before the form
is
displayed to the user. The issue is that when I attempt to set the
select
index, etc. prior to showing the form, I get a error:
System.ArgumentOutOfRangeException: Specified argument was out of the
range
of valid values.
Parameter name: '2' is not a valid value for 'index'.
However, when I perform the same command after the form is loaded, ex.
via.
a button, it works. I have to assume that something on the form is
not set
prior to final form loading.
So, where can I place my code so that it will run after the datasource
pointers are set up and prior to the user getting their hands on the
form?
Eg. should I put it in a event? I tried the form load, but also too
early.
Or is there another way to approach this issue.
DataSource
method.
Eg:
this.comboBox.DataSource = a1;
this.comboBox.DisplayMember = "name";
this.comboBox.ValueMember = "key";
I also need to set the displayed item in the combobox before the form
is
displayed to the user. The issue is that when I attempt to set the
select
index, etc. prior to showing the form, I get a error:
System.ArgumentOutOfRangeException: Specified argument was out of the
range
of valid values.
Parameter name: '2' is not a valid value for 'index'.
However, when I perform the same command after the form is loaded, ex.
via.
a button, it works. I have to assume that something on the form is
not set
prior to final form loading.
So, where can I place my code so that it will run after the datasource
pointers are set up and prior to the user getting their hands on the
form?
Eg. should I put it in a event? I tried the form load, but also too
early.
Or is there another way to approach this issue.