I have a DataGridView bound to a DataTable that has 1+16 columns defined as Integer.
The default cell style is hexadecimal 2 digits (.Format="X2"
).
When entering in cell editing I would like to provide to the user, the possibility to write the value in decimal or hexdacimal.
- Hexadecimal could be written like, for example, 0x00, 0X01, x02, XFF
- Decimal like 0, 1, 2, 15
For this reason in EditingControlShowing I add "0x" to the TextBox value
Private Sub BankGrid_EditingControlShowing(ByVal sender As Object, ByVal e As DataGridViewEditingControlShowingEventArgs)
Dim grid As DataGridView = DirectCast(sender, DataGridView)
If Not TypeOf e.Control Is TextBox Then Return
Dim tb As TextBox = DirectCast(e.Control, TextBox)
tb.Text = "0x" & tb.Text
RemoveHandler tb.KeyPress, AddressOf TextBox_KeyPress
AddHandler tb.KeyPress, AddressOf TextBox_KeyPress
End Sub
while in TextBox_KeyPress sub I perform all input filtering to avoid invalid inputs.
What I cannot understand is to which event may I attach to detect when the editing is finished. I would like something opposite to EditingControlShowing so that I can remove "0x" but I didn't found it.