|
-
May 24th, 2005, 05:29 AM
#1
Thread Starter
Lively Member
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
-
May 27th, 2005, 09:14 AM
#2
Thread Starter
Lively Member
Re: Validating input of datagrid?
any help...?
-
Jun 3rd, 2005, 08:42 AM
#3
Thread Starter
Lively Member
Re: Validating input of datagrid?
Can you please help me with it...?
-
Jun 3rd, 2005, 01:35 PM
#4
Hyperactive Member
Re: Validating input of datagrid?
Brenda
If it weren't for you guys, where would I be?
-
Jun 3rd, 2005, 02:19 PM
#5
Thread Starter
Lively Member
Re: Validating input of datagrid?
VB .NET
This is what I have
VB Code:
Dim dgts As New DataGridTableStyle
dgts.MappingName = DirectCast(dtgTechInfo.DataSource, DataView).Table.TableName
Dim dgtbc1 As New DataGridTextBoxColumn
dgtbc1.MappingName = "ITtechname"
dgtbc1.HeaderText = "Technician name"
dgtbc1.Width = 100
dgts.GridColumnStyles.Add(dgtbc1)
Dim dgtbc2 As New DataGridTextBoxColumn
dgtbc2.MappingName = "Phone"
dgtbc2.HeaderText = "Phonenumber"
dgtbc2.Width = 100
dgts.GridColumnStyles.Add(dgtbc2)
Dim dgtbc3 As New DataGridTextBoxColumn
dgtbc3.MappingName = "Email"
dgtbc3.HeaderText = "Email address"
dgtbc3.Width = 100
dgts.GridColumnStyles.Add(dgtbc3)
dtgTechInfo.TableStyles.Add(dgts)
I want to validate..so the user can enter letters only for name, digits only for number....
thanx
-
Jun 4th, 2005, 09:52 AM
#6
Thread Starter
Lively Member
Re: Validating input of datagrid?
-
Jun 4th, 2005, 08:25 PM
#7
New Member
Re: Validating input of datagrid?
Hola , i had this question and its resolves with:
For numbers only :
VB Code:
Public Class DataGridDigitsTextBoxColumn
Inherits DataGridTextBoxColumn
Public Sub New()
AddHandler Me.TextBox.KeyPress, New System.Windows.Forms.KeyPressEventHandler(AddressOf HandleKeyPress)
End Sub
Private Sub HandleKeyPress(ByVal sender As Object, ByVal e As KeyPressEventArgs)
If (Not (System.Char.IsDigit(e.KeyChar)) AndAlso Not (System.Char.IsControl(e.KeyChar)) AndAlso e.KeyChar <> ".") Then
e.Handled = True
End If
End Sub
End Class
For letters only :
VB Code:
Public Class DataGridLettersTextBoxColumn
Inherits DataGridTextBoxColumn
Public Sub New()
AddHandler Me.TextBox.KeyPress, New System.Windows.Forms.KeyPressEventHandler(AddressOf HandleKeyPress)
End Sub
Private Sub HandleKeyPress(ByVal sender As Object, ByVal e As KeyPressEventArgs)
If Not (System.Char.IsLetter(e.KeyChar) Then
e.Handled = True
End If
End Sub
End Class
I hope that this helps you.
Grettings for Mexico.
Saludos desde Mexico.
-
Jun 5th, 2005, 01:24 AM
#8
Thread Starter
Lively Member
Re: Validating input of datagrid?
Thank jorgegc
but do I have to have single classes..like what you have?
Thanx
-
Jun 6th, 2005, 03:54 PM
#9
New Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|