I have a datagridviewcombobox column, which works well only when the VirtualMode property is false. Otherwise, the value selected from the list will not be displayed in the column. This is added like this
DataGridViewComboBoxColumn colCategory = new DataGridViewComboBoxColumn();colCategory.Name =
Consts.DATAGRID_CATEGORY;colCategory.DataPropertyName =
Consts.DATAGRID_CATEGORY;colCategory.HeaderText =
Consts.DATAGRID_CATEGORY.ToString();colCategory.SortMode =
DataGridViewColumnSortMode.Automatic;colCategory.Items.AddRange(
new string[] { "Subsystem", "Library", "Unknown", "Hole" }); this.dgBudgetInfo.Columns.Insert(1, colCategory);Also, I am generating the serial no automatically like this:
private
void dgBuildFile_NewRowNeeded(object sender, DataGridViewRowEventArgs e){
this.dgBuildFile.Rows[this.dgBuildFile.Rows.Count - 1].Cells[0].Value = this.GetNewSlNo();}
This works only when the VirtualMode property is set to true.
BTW, I cannot take an AutoIncrement column for various other reasons.
Is there any workaround to achieve both of them in the same datagrid?

Bechir BejaouiRank #144 · 15.9K reputationPosted Dec 11, 2008, 1:58 AM EST
datagridview.VirtualMode = true;
//Your code
datagridview.VirtualMode = flase;
like that
Srinivas kadiyala5 reputationPosted Dec 11, 2008, 2:26 AM EST
Thanks for the suggestion.
But it works only for the first row. After I enter one row and go to the new row it doesn't work. Any reasons for this behavior??
Bechir BejaouiRank #144 · 15.9K reputationPosted Dec 11, 2008, 1:16 PM EST
Vugar196 reputationPosted Feb 17, 2009, 7:47 AM EST