Results 1 to 9 of 9

Thread: Validating input of datagrid?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2005
    Posts
    120

    Validating input of datagrid?

    Hello,


    Is there a way to validate the user's entries to the Datagrid, for example Letters only or Digits onle..etc...


    Thanks,
    Sushu

  2. #2

    Thread Starter
    Lively Member
    Join Date
    May 2005
    Posts
    120

    Re: Validating input of datagrid?

    any help...?

  3. #3

    Thread Starter
    Lively Member
    Join Date
    May 2005
    Posts
    120

    Re: Validating input of datagrid?

    Can you please help me with it...?

  4. #4
    Hyperactive Member
    Join Date
    Jun 2004
    Location
    Utah, USA
    Posts
    353

    Re: Validating input of datagrid?

    In ASP.NET or VB.NET?
    Brenda

    If it weren't for you guys, where would I be?

  5. #5

    Thread Starter
    Lively Member
    Join Date
    May 2005
    Posts
    120

    Re: Validating input of datagrid?

    VB .NET

    This is what I have

    VB Code:
    1. Dim dgts As New DataGridTableStyle
    2.         dgts.MappingName = DirectCast(dtgTechInfo.DataSource, DataView).Table.TableName
    3.  
    4.         Dim dgtbc1 As New DataGridTextBoxColumn
    5.         dgtbc1.MappingName = "ITtechname"
    6.         dgtbc1.HeaderText = "Technician name"
    7.         dgtbc1.Width = 100
    8.         dgts.GridColumnStyles.Add(dgtbc1)
    9.  
    10.  
    11.         Dim dgtbc2 As New DataGridTextBoxColumn
    12.         dgtbc2.MappingName = "Phone"
    13.         dgtbc2.HeaderText = "Phonenumber"
    14.         dgtbc2.Width = 100
    15.         dgts.GridColumnStyles.Add(dgtbc2)
    16.  
    17.         Dim dgtbc3 As New DataGridTextBoxColumn
    18.         dgtbc3.MappingName = "Email"
    19.         dgtbc3.HeaderText = "Email address"
    20.         dgtbc3.Width = 100
    21.         dgts.GridColumnStyles.Add(dgtbc3)
    22.  
    23.         dtgTechInfo.TableStyles.Add(dgts)

    I want to validate..so the user can enter letters only for name, digits only for number....

    thanx

  6. #6

    Thread Starter
    Lively Member
    Join Date
    May 2005
    Posts
    120

    Re: Validating input of datagrid?

    Any one knows...?

  7. #7
    New Member
    Join Date
    Jun 2005
    Posts
    7

    Re: Validating input of datagrid?

    Hola , i had this question and its resolves with:

    For numbers only :

    VB Code:
    1. Public Class DataGridDigitsTextBoxColumn
    2.     Inherits DataGridTextBoxColumn
    3.  
    4.     Public Sub New()
    5.         AddHandler Me.TextBox.KeyPress, New System.Windows.Forms.KeyPressEventHandler(AddressOf HandleKeyPress)
    6.  
    7.     End Sub
    8.  
    9.     Private Sub HandleKeyPress(ByVal sender As Object, ByVal e As KeyPressEventArgs)
    10.  
    11.         If (Not (System.Char.IsDigit(e.KeyChar)) AndAlso Not (System.Char.IsControl(e.KeyChar)) AndAlso e.KeyChar <> ".") Then
    12.             e.Handled = True
    13.         End If
    14.  
    15.     End Sub
    16. End Class

    For letters only :

    VB Code:
    1. Public Class DataGridLettersTextBoxColumn
    2.     Inherits DataGridTextBoxColumn
    3.  
    4.     Public Sub New()
    5.         AddHandler Me.TextBox.KeyPress, New System.Windows.Forms.KeyPressEventHandler(AddressOf HandleKeyPress)
    6.  
    7.     End Sub
    8.  
    9.     Private Sub HandleKeyPress(ByVal sender As Object, ByVal e As KeyPressEventArgs)
    10.  
    11.         If Not (System.Char.IsLetter(e.KeyChar) Then
    12.             e.Handled = True
    13.         End If
    14.  
    15.     End Sub
    16. End Class

    I hope that this helps you.
    Grettings for Mexico.
    Saludos desde Mexico.

  8. #8

    Thread Starter
    Lively Member
    Join Date
    May 2005
    Posts
    120

    Re: Validating input of datagrid?

    Thank jorgegc


    but do I have to have single classes..like what you have?


    Thanx

  9. #9
    New Member
    Join Date
    Jun 2005
    Posts
    7

    Re: Validating input of datagrid?

    I don't understand your cuestion (my english not is very good, but i try to understand) , you can do more especific ?


    Saludos

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