Winform datagrid - cell value rejected using Alt key instead of bu

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a Winform with a derived datagrid and a button that adds a row to the
datagrid in its Click event. The button has a shortcut text "&New Row".
When I enter a value in a datagrid cell and then mouse click the button
without tabbing out of the edited cell, everything is fine. If I hit Alt+N
instead after editing the cell, the cell values are reset to the previous
value of the cell before the button_click code is executed. I have tried
trapping various Key_down events, PreProcessMessage, etc. and this seems to
take place even before that. It seems that CancelEdit is implicitly being
called.

I would greatly appreciate any ideas about why this might be happening.
Thanks!!!
 
Hi,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that when you're trying to use a shortcut
key to perform a button click and the editing cell value was rolled back.
If there is any misunderstanding, please feel free to let me know.

I tried this with a winform DataGrid control and it seem that there isn't
such problem happening. I think this issue might have something to do with
the derived datagrid. I suggest that you try to get the CurrencyManager of
the binding in Button.Click event and call EndCurrentEdit method explicitly
to see if it works.

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Hi Kevin,

Thank you for your help! I did try the CurrencyManager.EndCurrentEdit in
the button click and in other events, but it was not doing the trick. It did
lead me in the right direction and I was able to solve the problem by adding
a handler to the DatagridTextboxcolumn.Textbox's Validating event. In there
I called the Datagrid.EndEdit and the problem was fixed.

Thanks again!
 
You're welcome! Thanks for sharing your experience with all the people
here. If you have any questions, please feel free to post them in the
community.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Back
Top