Results 1 to 3 of 3

Thread: Onvalidating in editorcontrol

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2006
    Posts
    1

    Onvalidating in editorcontrol

    Hi,

    I made my own DataGridViewEditingControl, DataGridViewCell and DataGridViewColumn.
    Is it possible to use an Onvalidating event in an editing control in a datagridview?
    I wrote something like this:
    Code:
    Code:

    Code:
    Protected Overrides Sub OnValidating(ByVal e As System.ComponentModel.CancelEventArgs) 
       MyBase.OnValidating(e)
       If Me.Text <> String.Empty Then
          If Me.Text <> "CORRECT"
             e.Cancel = True
          End If
       End If
    End Sub
    But when tabbing out the cell it gets executed twice plus that the incorrect value in the cell remains and the I can continue to edit in other cells.The event is correctly handled when I click somewhere else with the mouse (being the cursor remaining in the cell until a correct value is given).

    Do I need to do something special when the tab key is pressed.

    Any help is appreciated.

    Thanks in advance.

  2. #2
    Lively Member
    Join Date
    Dec 2004
    Posts
    97

    Re: Onvalidating in editorcontrol


  3. #3
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Onvalidating in editorcontrol

    The problem is that Tab is both an acceptable character in your editing control and a control key in the DGV. It may be as simple as excluding the Tab from your editing control (OnKeyDown filter, perhaps) so that it can act solely as a control key.
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width