How do I set a column in child table to ignore non-numeric characters while a user is entering data?

In a Grid Grouping Control, How do I set a column in child table to ignore non-numeric characters while a user is entering data? I am developing in VB.Net. The column I need to make numeric only is defined as a TextBox.

4 Replies

AD Administrator Syncfusion Team May 6, 2006 11:55 PM UTC

Hi Steve, You can acheive this by handling the TableControlCurrentCellValidateString event and canceling it for a non-numeric entry. Please refer this code snippet: AddHandler gridGroupingControl1.TableControlCurrentCellValidateString, AddressOf Grid_CurrentCellValidateString Private Sub Grid_CurrentCellValidateString(ByVal sender As Object, ByVal e As GridTableControlCurrentCellValidateStringEventArgs) ''Get the CurrentCell Dim cc As GridCurrentCell = Me.gridGroupingControl1.TableControl.GetNestedCurrentCell() ''Get the Style Dim style As GridTableCellStyleInfo = CType(e.TableControl.GetViewStyleInfo(cc.RowIndex, cc.ColIndex), GridTableCellStyleInfo) ''Check for the ChildTable If (style.TableCellIdentity.Column.TableDescriptor.ToString() = "MyChildTable") Then ''Check for the Column name in the Table If (style.TableCellIdentity.Column.Name = "Name") Then '' Accept only decimal digits Dim c As Char For Each c In e.Inner.Text If (Char.IsDigit(c) = False) Then e.Inner.Cancel = True End If Next End If End If End Sub Attached is the modified Grid.Grouping.Windows\Samples\ManualRelations sample that handles this for the childtable''s "Name" column. Best regards, Jay ManualRelations_VB.zip


SK Steve Killingsworthnolongercoding.NET May 8, 2006 03:08 PM UTC

Thanks for your reply...I am having problems with the following line of your code snipet: AddHandler gridGroupingControl1.TableControlCurrentCellValidateString, AddressOf Grid_CurrentCellValidateString vb.Net gives a syntax error with AddHandler. Is there something I need to do to get this to work?


AD Administrator Syncfusion Team May 8, 2006 09:37 PM UTC

Hi Steve, It just associates the event (TableControlCurrentCellValidateString) with the eventhandler (Grid_CurrentCellValidateString): http://msdn2.microsoft.com/en-us/library/7taxzxka.aspx Please make sure that the handler signature is correct: Private Sub Grid_CurrentCellValidateString(ByVal sender As Object, ByVal e As GridTableControlCurrentCellValidateStringEventArgs I could able to compile the sample without any issues. You can also subscribe to the event as you normally do (http://www.syncfusion.com/support/kb/studio/Default.aspx?ToDo=view&questId=7) and add the above code to the eventhandler method. Best regards, Jay


AD Administrator Syncfusion Team May 9, 2006 06:44 PM UTC

Thanks, It works now...

Loader.
Up arrow icon