Detecting Keystrokes in a DataTable

  • Thread starter Thread starter Randy
  • Start date Start date
R

Randy

I have a DataTable in a DataGrid on a Windows form.

I have comboboxes in the first column, and that seems to work just fine.

The second column is for a money amount. The numeric dollar value doesn't
get saved to the cell until I hit <Enter> or tab to the next cell.

I'd really like to be able to detect each keystroke in the cell, so it would
be just like an Excel spreadsheet. I'd settle for the ability to save
whatever numbers are in the cell with a button press - like when I hit my
Save button.

Any thoughts are appreciated...

Randy
 
How are your comboboxes implemented? It sounds like it's in an Edit state
and the only events on the table are RowChanging, Changed, ColumnChanging,
Changed so you are going to have to trap those through the control.

--

W.G. Ryan, eMVP

Have an opinion on the effectiveness of Microsoft Embedded newsgroups?
Let Microsoft know!
https://www.windowsembeddedeval.com/community/newsgroups
 
The first column, the combobox column, is implemented with
DataGridComboBoxColumn, which inherits from DataGridTextBoxColumn, and
overrides Edit, GetColumnValueAtRow, SetColumnValueAtRow, and has a combobox
leave event.

The second column is DataGridMoneyColumnStyle, which is just a
DataGridTextBoxColumn with formatting for dollars and cents.

Are you suggesting I need to override Edit in my DataGridMoneyColumnStyle
class?

In my form class, I setup event handlers for RowChanging, Changed,
ColumnChanging, Changed, but those only fire after hitting tab or <Enter> in
the money column cell. Again, my goal is fire an event after each keystroke
in the money cell, just like an Excell spreadsheet would do.

Thanks,
Randy
 
Back
Top