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?
VugarPosted Feb 17, 2009, 12:47 PM
Bechir BejaouiPosted Dec 11, 2008, 6:16 PM
Srinivas kadiyalaPosted Dec 11, 2008, 7:26 AM
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 BejaouiPosted Dec 11, 2008, 6:58 AM
datagridview.VirtualMode = true;
//Your code
datagridview.VirtualMode = flase;
like that