Hi there
I have a datagridview problem that I can;t resolve .. I'm using VS 2005 with vb.net. I've only moved to .Net2 a week ago, so am still getting used to the new features.
Basically I am binding a dataview to a datagridview and then making a particular column editable. When the user changes a value in this column (initially all values in the column are blank) I want to be able to immediately catch the change, validate it and then either allow it or re-set it if not valid. I DO NOT however want to wait until the user clicks out of the current cell before I carry out this validation.
Consequently I have the "CurrentCellDirtyStateChanged" event captured which then calls the "CellValueChanged" event via a CommitEdit command on the grid. If I don't call the CommitEdit then I can't access the new value enterd by the user (or can I?).
So once I enterthe CellValueChanged code the new value entered by the user is now commited (before I've had a chance to validate it), so I carry out the validation and if it fails I try to set currentcell.value = "". However the grid fails to update and only does so when I exit the currentcell. If I call another CommitEdit then I get caught in a recursive loop which i have tried to exit using a flag .. but still the grid refuses to update UNTIL I exit the cell.
I have hunted high and low to find a solution to this but have been unsuccessful so far .. any help would be much appreciated. I have tried a myriad of different datagridview events (Validating, CellParsing etc .. but these all rely on the user clicking out of the current cell).
regards
Andy
I have a datagridview problem that I can;t resolve .. I'm using VS 2005 with vb.net. I've only moved to .Net2 a week ago, so am still getting used to the new features.
Basically I am binding a dataview to a datagridview and then making a particular column editable. When the user changes a value in this column (initially all values in the column are blank) I want to be able to immediately catch the change, validate it and then either allow it or re-set it if not valid. I DO NOT however want to wait until the user clicks out of the current cell before I carry out this validation.
Consequently I have the "CurrentCellDirtyStateChanged" event captured which then calls the "CellValueChanged" event via a CommitEdit command on the grid. If I don't call the CommitEdit then I can't access the new value enterd by the user (or can I?).
So once I enterthe CellValueChanged code the new value entered by the user is now commited (before I've had a chance to validate it), so I carry out the validation and if it fails I try to set currentcell.value = "". However the grid fails to update and only does so when I exit the currentcell. If I call another CommitEdit then I get caught in a recursive loop which i have tried to exit using a flag .. but still the grid refuses to update UNTIL I exit the cell.
I have hunted high and low to find a solution to this but have been unsuccessful so far .. any help would be much appreciated. I have tried a myriad of different datagridview events (Validating, CellParsing etc .. but these all rely on the user clicking out of the current cell).
regards
Andy