Hello,
Is there a way to validate the user's entries to the Datagrid, for example Letters only or Digits onle..etc...
Thanks,
Sushu
Printable View
Hello,
Is there a way to validate the user's entries to the Datagrid, for example Letters only or Digits onle..etc...
Thanks,
Sushu
any help...? :sick:
Can you please help me with it...?
In ASP.NET or VB.NET?
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
Any one knows...?
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. :wave:
Grettings for Mexico. ;)
Saludos desde Mexico. :)
Thank jorgegc :)
but do I have to have single classes..like what you have?
Thanx :)
I don't understand your cuestion (my english not is very good, but i try to understand) , you can do more especific ?
Saludos :thumb: