hi why is the difference between normal combobox and the combobox in datagrid? imean to say im not able to give my value in combobox(in datagrid) but im able to give (type any value) in normal combos.
waiting for answers thanx srini.
hi why is the difference between normal combobox and the combobox in datagrid? imean to say im not able to give my value in combobox(in datagrid) but im able to give (type any value) in normal combos.
waiting for answers thanx srini.
The combobox control has its dropdown style set as dropdown. Thus you can type in values in it. While the DataGridView's combobox column has the property set as DropDownList. This is the reason you cannot type in it. If you wish to type in it, you can do this using following code:
private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) {
if (e.Control.GetType() == typeof(DataGridViewComboBoxEditingControl)) {
DataGridViewComboBoxEditingControl edit = e.Control as DataGridViewComboBoxEditingControl;
edit.DropDownStyle = ComboBoxStyle.DropDown;
}
}
Apart from this, you will need to handle the validating event of DataGridViewComboBoxEditingControl to decide what to do when user types value in the combobox.
the "Normal" combobox or the System.Windows.Forms.ComboBox is a Windows Form user control which is used to display multiple values of which a user may choose ONE option. The ComboBox.DropDownStyle which is of type ComboBoxStyle Enumeration property defines the behaviour of the text portion of the combo box is editable or not.
"Data grid" combo box is System.Windows.Forms.DataGridViewComboBoxColumn class which Represents a column of DataGridViewComboBoxCell objects. This class exhibits the almost behavior of "Normal" combobox, but the class hierarchy (deriving from DataGridViewColumn) is such that it can be embedded into a Datagrid.
View the source and you will notice the GridView's combobox control's id isn't what you would expect. This is because it is running at server and it's id is generated using its naming container, etc. If you reference the .NET-generated id (the one you see in the source) you should be able to manipulate the GridView's combobox accordingly.
I'm guessing the "normal" combobox isn't running at server and its id doesn't change thus you can reference the control as expected.
Just a hunch, but I hope it helps