I currently have a DataGridView which depending on certain row states (which I have defined as "new", "modified", "to be removed" & "normal") I Style rows within my grid with code like this:
'Modified
row.DefaultCellStyle.Font = New Font(row.DataGridView.Font, FontStyle.Regular)
row.DefaultCellStyle.BackColor = Color.LemonChiffon
row.DefaultCellStyle.ForeColor = Color.Empty
I hook on to various events to accomplish this - and they fire when I expect them.
My issue is that I am using My DataGridView
in the EditMode
of EditOnEnter
. I'm running into an issue that whichever cell is selected (& therefor in edit mode) is not being updated immediately by my Style change code. That is until I leave the selected cell for another one.
Here is a couple screen-shots which show's the life-cycle of this issue:
Before editing anything
After modifying a cell
After tabbing to another cell
My Desired result would be transitioning from the first image - directly to the last image (Without having to "tab" out of the cell I'm editing.) Is there something I can do to accomplish this?
Thanks.
P.S. I'm normally code in C# so I can accept the answer in either langua开发者_JAVA百科ge (this project just so happens to be in vb.net v2.0)
I know this is a little old, but I was searching for awhile to find an answer to this, so I figure it might help someone in the future:
I was able to solve this by attaching to the 'CellFormatting' event, to 'unselect' the cell when the format has been changed.
this.DataGridView.CellFormatting +=
(s, e) => { this.DateGridView.ClearSelection(); }
精彩评论