A
andersonwebdev
When I use the DataSource property of a ListBox or ComboBox, there is
always a selected item. When I bind the control, I don't want anything
selected. I have tried using the .SetSelected() method, setting,
selectedIndex to -1 (twice in a row, blah blah), setting SelectedItem
to null, etc.
listBoxInventorParts.DataSource = _selectedInventorParts;
listBoxInventorParts.DisplayMember = "InventorPartNumber";
listBoxInventorParts.ValueMember = "pkInventorPartId";
// Doesn't work
listBoxInventorParts.SelectedIndex = -1;
// Doesn't work
listBoxInventorParts.SelectedItem = null;
// Doesn't work
listBoxInventorParts.SelectedValue = null;
// Doesn't work
listBoxInventorParts.ClearSelected();
// Doesn't work
for(int i = 0; i < listBoxInventorParts.Items.Count; i++)
{
listBoxInventorParts.SetSelected(i, false);
}
Nice.
always a selected item. When I bind the control, I don't want anything
selected. I have tried using the .SetSelected() method, setting,
selectedIndex to -1 (twice in a row, blah blah), setting SelectedItem
to null, etc.
listBoxInventorParts.DataSource = _selectedInventorParts;
listBoxInventorParts.DisplayMember = "InventorPartNumber";
listBoxInventorParts.ValueMember = "pkInventorPartId";
// Doesn't work
listBoxInventorParts.SelectedIndex = -1;
// Doesn't work
listBoxInventorParts.SelectedItem = null;
// Doesn't work
listBoxInventorParts.SelectedValue = null;
// Doesn't work
listBoxInventorParts.ClearSelected();
// Doesn't work
for(int i = 0; i < listBoxInventorParts.Items.Count; i++)
{
listBoxInventorParts.SetSelected(i, false);
}
Nice.