Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 849093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T07:03:00+00:00 2026-05-15T07:03:00+00:00

I have a DataGridView bound to a DataTable that has 1+16 columns defined as

  • 0

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.

  1. Hexadecimal could be written like, for example, 0x00, 0X01, x02, XFF
  2. 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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T07:03:01+00:00Added an answer on May 15, 2026 at 7:03 am

    After try all possible events both in TextBox and in DataGRidView I finally found one useful for my case.

    CellParsing

    I copy my code maybe it could help someone else 🙂

       Private Sub BankGrid_CellParsing(ByVal sender As Object, ByVal e As DataGridViewCellParsingEventArgs)
    
            Dim grid As DataGridView = DirectCast(sender, DataGridView)
            Dim cell As CustomCell = DirectCast(grid(e.ColumnIndex, e.RowIndex), CustomCell)
    
            If e.Value Is Nothing OrElse String.IsNullOrEmpty(e.Value.ToString) Then
                e.Value = cell.Value
            Else
    
                Dim iValue As Integer
                If TryParseNumeric(e.Value.ToString, iValue) Then
    
                    If iValue >= 0 AndAlso iValue <= &HFF Then
                        e.Value = iValue  'value inside the range, accept it'
                    Else
                        e.Value = cell.Value 'value outside the range, reload old value'
                    End If
    
                Else                    
                    e.Value = cell.Value 'invalid input, reload old value'
                End If
    
            End If
    
            e.ParsingApplied = True
    
        End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.