1st combo box item selected in Form_Load after Data Bind.

1st combo box item selected in Form_Load after Data Bind.

Post by David » Tue, 09 Dec 2003 14:09:21


Hi,

This would seem to be a variation on a well known issue
with .NET Windows Forms Combo Boxes, however, I was
wondering if anyone has had any success with it in the
mean time.

I have a combo box which I data bind in the Form_Load
event. The 1st item in the data source is selected.
However, for my purposes, the combo box should have no
selected item. Setting the SelectedIndex property to -1
has no effect. The 1st item is still selected. Here is my
code :

private void JobViewWinForm_Load(object sender,
System.EventArgs e)
{
....

// Populate Job Status Combo. Deselect item.
DataSet __JobStatusDataSet =
JobBusinessObject.RetrieveJobStatus();
jobStatusComboBox.DataSource =
__JobStatusDataSet.Tables[0];
jobStatusComboBox.ValueMember = "JobStatusID";
jobStatusComboBox.DisplayMember = "Description";
jobStatusComboBox.SelectedIndex = -1;

// Setup DataGrid - Do search for all jobs.
//Search();

....

}

I would like to have the combo box unselected,
particularly, because the Search method looks at the combo
to see if anything is selected. But, of course, on
Form_Load, nothing should be.

Thanks,
David.
 
 
 

1st combo box item selected in Form_Load after Data Bind.

Post by Claes Berg » Tue, 09 Dec 2003 17:38:41

http://www.yqcomputer.com/ ;en-us;327244

/claes

 
 
 

1st combo box item selected in Form_Load after Data Bind.

Post by hirf-spam- » Tue, 09 Dec 2003 21:43:55

* "David R" < XXXX@XXXXX.COM > scripsit:

Set 'SelectedIndex' to -1 /twice/.

--
Herfried K. Wagner [MVP]
< http://www.yqcomputer.com/ ;