Problem with Datagridview Combobox column...
-
I have added one combobox column to datagrid view in my windows application. In Combobox items added is 1,2,3,4,5 even the items has been added it doesn't Display anything in my combobox.When i click on arrow of combobox column,it shows added items 1,2,3,4,5 I want atleast one item must be displayed there in combo box by default. i.e There must be one selected item.
-
I have added one combobox column to datagrid view in my windows application. In Combobox items added is 1,2,3,4,5 even the items has been added it doesn't Display anything in my combobox.When i click on arrow of combobox column,it shows added items 1,2,3,4,5 I want atleast one item must be displayed there in combo box by default. i.e There must be one selected item.
-
first of all thanks for answer darkelv. For datagridview combobox column there is no selected index property. yes it is bound. I has set displaymember,Valuemember property according to i need it.
-
I have added one combobox column to datagrid view in my windows application. In Combobox items added is 1,2,3,4,5 even the items has been added it doesn't Display anything in my combobox.When i click on arrow of combobox column,it shows added items 1,2,3,4,5 I want atleast one item must be displayed there in combo box by default. i.e There must be one selected item.
-
first of all thanks for answer darkelv. For datagridview combobox column there is no selected index property. yes it is bound. I has set displaymember,Valuemember property according to i need it.
Maybe check if the binding is bound to the correct item/property. Here's a sample of my code that is bound to an array of enum Edit: Are you using comboBoxColumn.Items.Add() instead of setting DataSource?
//==Status==//
public static AtomDataGridViewComboBoxColumn StatusGridViewColumn(Atom.Interface.ILocale locale)
{
AtomDataGridViewComboBoxColumn status = new AtomDataGridViewComboBoxColumn();
status.DataPropertyName = "Status";
status.HeaderText = LocalText.GetText(locale, LocalID.Create("ChequePrint.Master.Cheque_Status"), "Status");
status.Name = "Status";
status.SortMode = DataGridViewColumnSortMode.Automatic;
status.ReadOnly = false;
status.Width = 90;
status.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
status.DefaultCellStyle.Format = "";
//===== MUST HANDLE DATA FILL FOR COMBO BOX HERE =====//
#region .:BE831DCA-BCDC-4294-8634-E33D8C66E51E [Status]:.
ArrayList a = new ArrayList();
a.Add(StatusTypes.Outstanding);
a.Add(StatusTypes.Issued);
a.Add(StatusTypes.Cleared);
a.Add(StatusTypes.Void);
Array enums = a.ToArray(typeof(StatusTypes));
//Array enums = Enum.GetValues(typeof(StatusTypes));
status.DataSource = enums;
#endregion .:BE831DCA-BCDC-4294-8634-E33D8C66E51E [Status]:.
return status;
} -
DataGridViewComboBoxColumn DataGridViewComboBoxCell doesn't have selectedindex or selectedvalue, so you must use Value property instead.
The need to optimize rises from a bad design.My articles[^]
modified on Friday, January 23, 2009 5:05 AM
Is it possible to add full DataGridViewComboBoxColummn to DataGridView with the use of DataGridViewComboBoxCell.
modified on Friday, January 23, 2009 6:11 AM
-
Is it possible to add full DataGridViewComboBoxColummn to DataGridView with the use of DataGridViewComboBoxCell.
modified on Friday, January 23, 2009 6:11 AM
-
My bad, I didn't mean the column but the cell. DataGridViewComboBoxCell has the value property and it doesn't have selectedindex or selectedvalue.
The need to optimize rises from a bad design.My articles[^]
Is it possible to add full DataGridViewComboBoxColummn to DataGridView with the use of DataGridViewComboBoxCell.
-
Is it possible to add full DataGridViewComboBoxColummn to DataGridView with the use of DataGridViewComboBoxCell.
I don't quite understand your question. The DataGridViewComboBoxColumn represents the column itself while the cells is one cell in that column on a specified row. I think there's a very good example here: DataGridViewComboBoxColumn Class[^]
The need to optimize rises from a bad design.My articles[^]
-
I have added one combobox column to datagrid view in my windows application. In Combobox items added is 1,2,3,4,5 even the items has been added it doesn't Display anything in my combobox.When i click on arrow of combobox column,it shows added items 1,2,3,4,5 I want atleast one item must be displayed there in combo box by default. i.e There must be one selected item.
Can you please try this :
Dim rowCounter as Integer = 0
With CType(Grid.Rows(rowCounter).Cells(0), DataGridViewComboBoxCell)
.Items.Add("1")
.Items.Add("2")
.Items.Add("3")
.Items.Add("4")
.Value = .Items.Item(ind)
End WithHope this will answer your query
dnpro "Very bad programmer" My Latest Articles RichTextBox Control with Find functionality LogViewer - A Simple Log Listening Utility