-2

How to prevent Combobox to select first item on databinding to DataSource.

I also have a datagridview table - where when the user selects a row on of the cells goes into the combobox - but I want it to override what ever is in the combobox with item from the table.

I have

PD.ItemCBx.Text = this.cOrdersDGV.CurrentRow.Cells[2].Value.ToString();

from form1 which fills the combobox. But when form 2 is opened the combobox is filled with the first item on the databinding to DataSource.

I've tried

ItemCBx.SelectedIndex = -1;

but this stops the data being transfered.

Peter B
  • 22,460
  • 5
  • 32
  • 69
Linda T
  • 15
  • 4

1 Answers1

-1

"The way you "deselect" an item in a drop-down ComboBox is by selecting a different item."

"There is no "deselect" option for a ComboBox—something always has to be selected."

"If you want to simulate the behavior where nothing is selected, you'll need to add a item (or equivalent) to the ComboBox."

"The user can then select this option when they want to "deselect"."

Check out the link below: https://stackoverflow.com/a/25329202/9808334

LudacrisX1
  • 330
  • 1
  • 5
  • 12