vb-dev
2023-05-12T17:37:01Z
I have read the relevant parts of the manual and experimented with all the TextBox related events including TextBoxFilterChar. However, I am unable to come up with a solid solution to satisfy all of the following rules.

1. Prevent paste into TextBox using Ctrl-V
2. Prevent paste into TextBox using Shift-Insert
3. Prevent typing of any char into TextBox

Thanks for any/all assistance.
vb-dev
2023-05-12T18:12:57Z
I am also confused by some of the TextBoxKey events, such as in TextBoxKeyDown:

e.DoDefault's tooltip says "Determines whether to accept the key or not". But even with e.DoDefault set to False, the key is accepted.

        Private Sub ImbalancesGrid_TextBoxKeyDown(sender As Object, e As iGTextBoxKeyDownEventArgs) Handles ImbalancesGrid.TextBoxKeyDown
            e.DoDefault = False
        End Sub
Igor/10Tec
2023-05-15T07:44:46Z
"Determines whether to accept the key or not" in the context of the KeyDown event means disabling the action that is done from the KeyDown event, but for CTRL+V you should suppress the key press. Below is an example of how to disable CTRL+V in the fresh iGrid.NET v11 that provides the SuppressKeyPress property in the event args of the KeyDown event:


Private Sub IGrid1_TextBoxKeyDown(sender As Object, e As iGTextBoxKeyDownEventArgs) Handles IGrid1.TextBoxKeyDown
    If e.KeyValue = Keys.V And e.Modifiers = Keys.Control Then
        e.SuppressKeyPress = True
    End If
End Sub

You can do the same for SHIFT+INS and other keys.

Disabling any char input is implemented with the help of the TextBoxFilterChar event this way:


Private Sub IGrid1_TextBoxFilterChar(sender As Object, e As iGTextBoxFilterCharEventArgs) Handles IGrid1.TextBoxFilterChar
    e.Char = Chr(0)
End Sub

Prohibiting insertion may require other measures - for example, processing the textbox context menu with the paste command. If you cannot implement all this using the built-in iGrid tools but know how to do that in another WinForms control, you may think about implementing a custom editor inherited from the iGCellEditorBase class.