C# Programming
11-12-2009, 05:50 AM
Hi Guys,
i need the NewRowNeededEvent of the DataGridView. So i set the VirtualMode Property to true.
But if this property is set to true, i need to set the cell value by myself, otherwise it vanisches if i leave the cell.
So i've tried to save the value - the cell is a ComboBox where i select a value - in the CellValidatinEvent.
But it doesnt work. The value property of the cell is not changing it is still null.
Here is some code that you can understand what i mean.
private void aufwandDataGridView_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
{
DataGridViewComboBoxCell cell =
aufwandDataGridView.CurrentCell as DataGridViewComboBoxCell;
cell.ReadOnly = false;
if (aufwandDataGridView.IsCurrentCellDirty)
{
aufwandDataGridView.CommitEdit
(DataGridViewDataErrorContexts.Commit);
}
//e.FormattedValue contains the item thart i selected in the ComboBox
cell.Value = e.FormattedValue;
//cell.Value is not changing it is still null. no exception is thrown.
}
Can anyone please help me?
Kind regards and thx in advance
Me
i need the NewRowNeededEvent of the DataGridView. So i set the VirtualMode Property to true.
But if this property is set to true, i need to set the cell value by myself, otherwise it vanisches if i leave the cell.
So i've tried to save the value - the cell is a ComboBox where i select a value - in the CellValidatinEvent.
But it doesnt work. The value property of the cell is not changing it is still null.
Here is some code that you can understand what i mean.
private void aufwandDataGridView_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
{
DataGridViewComboBoxCell cell =
aufwandDataGridView.CurrentCell as DataGridViewComboBoxCell;
cell.ReadOnly = false;
if (aufwandDataGridView.IsCurrentCellDirty)
{
aufwandDataGridView.CommitEdit
(DataGridViewDataErrorContexts.Commit);
}
//e.FormattedValue contains the item thart i selected in the ComboBox
cell.Value = e.FormattedValue;
//cell.Value is not changing it is still null. no exception is thrown.
}
Can anyone please help me?
Kind regards and thx in advance
Me