This is a migrated thread and some comments may be shown as answers.

Validate Cell DataGrid

10 Answers 209 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Gilberth
Top achievements
Rank 1
Gilberth asked on 08 Jul 2009, 11:50 PM
Hello again, this is my doubt, I wish to validate a cell in GridView, this cell type is gridviewtextboxcolumn, this desire can only enter numeric values, ie, to type a letter or symbol I can not accept, do not put gridviewdecimalcolumn one because in this test can type a zero, eg 0101 and the gridviewdecimalcolumn not recognize me the first 0, I have not updated to the new version have taken Q2 because I found some bugs in this version, I'm just waiting for an answer to other post to see if it entered graduate or not, I have found this review validacion can be done with the event but editcontrolshowing datagrid visual studio that brings hope prompt response and thank you in advance for the help I provide.

Note: giving hope to understand, my English is not very good, thanks again.

10 Answers, 1 is accepted

Sort by
0
Gilberth
Top achievements
Rank 1
answered on 09 Jul 2009, 12:07 AM
    Searching I found as a solution using GridViewMaskBoxColumn, which allows me to enter numbers only, however if they have a better way, I thank you for the help, thanks
0
Jack
Telerik team
answered on 09 Jul 2009, 02:33 PM
Hello Gilberth,

I am glad to hear that you have found solution for this issue. Maybe this is the best option when using Q1 2009. I still recommend you try our latest release Q2 2009. It addresses many issues and contains several new features.

You can review our help article about data validation. If you have any other questions, don't hesitate to ask.

Kind regards,
Jack
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Gilberth
Top achievements
Rank 1
answered on 09 Jul 2009, 04:22 PM

Hello again, please see this ticket, these are the errors I found in the new Q2, therefore unwanted upgrade, I expect any positive response on these mistakes to follow your advice, thank you for answering.

http://www.telerik.com/account/support-tickets/view-ticket.aspx?threadid=225707

0
Jack
Telerik team
answered on 13 Jul 2009, 08:47 AM
Hello Gilberth,

Please find the answer in the support ticket.

Kind regards,
Jack
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Gilberth
Top achievements
Rank 1
answered on 13 Jul 2009, 04:08 PM
Hello, I wanted to respond on the same ticket, but did not find how to do it, if I understood well the error referred to is found in the latest version of the Q2 control MultiColumnComboBox This error occurs when you select an item from the list that contains , also to write some of the items, ie when the control is going to filter, this sends the same error, I put the code for the filter I found in the forum or that you gave me or that the Help do not remember where I got it right, even when pressing the button up or down key, I guess it should select an item from the list, but sends me the same error as comment is as follows:

Comboentradas.AutoFilter = True    
Dim filter_entrada As New FilterExpression(Comboentradas.DisplayMember, FilterExpression.BinaryOperation.AND, GridKnownFunction.StartsWith, GridFilterCellElement.ParameterName)   
filter_entrada.Parameters.Add(GridFilterCellElement.ParameterName, String.Empty)   
Comboentradas.EditorControl.MasterGridViewTemplate.FilterExpressions.Add(filter_entrada)   
Comboentradas.MultiColumnComboBoxElement.AutoCompleteMode = AutoCompleteMode.Suggest    

I hope to have given enterder error, Thanks for responding, hope I have helped somewhat in the evolution of these great controls and thanks for all the help I provide.

Edit:    One thing I like about the new version validacion Q2 is the GridView control, you can somehow do the same in the GridView control version of the Q1, the validacion to which I refer is when, for example, if the value is lower one above, the GridView puts an icon on the left side of the row, and the cell painted red, is something that I like and trying to make but could not find a way to do it, you can do in the old version Q1 ?, thanks again for everything.

0
Vassil Petev
Telerik team
answered on 13 Jul 2009, 04:26 PM
Hello Gilberth,

The validation feature is available since Q2 2009 - it is not possible out-of-the-box in Q1.

You are not able to reply in the ticket, because your trial support has expired. In case you have obtained copy of our controls through the company you work for, please ask the purchase holder in the company to add you as a License Developer to this purchase - this will unlock the support ticketing system. More on license Developers you can find here: http://www.telerik.com/account/faqs.aspx


Kind regards,
Vassil
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Rawad
Top achievements
Rank 2
answered on 07 Jul 2014, 08:07 AM
Dear Vassil Petev

How to prevent user to enter alphanumeric in some rows using GridViewTextBoxColum.
Lets say I have a grid with 2 columns GridViewTextBoxColum, I need for the second column for some rows (not all) that user just enter a numeric, or integer value,  for example

Column1          Column2
Name                (user here  can enter a string)
Age                    (user here can just enter a numeric)

Could you please give an example using VB.net .

Thanks
0
Stefan
Telerik team
answered on 10 Jul 2014, 05:56 AM
Hello Rawad,

Thank you for writing.

To do that you can use the CellValidating event and prevent the user from leaving the cell unless valid value is entered:
Private Sub radGridView1_CellValidating(sender As Object, e As CellValidatingEventArgs)
    Dim n As Integer
    Dim isNumeric As Boolean = Integer.TryParse(e.Value.ToString(), n)
 
    If e.Column.Name = "Column2" AndAlso e.Row.Cells("Column1").Value = "Age" AndAlso isNumeric = False Then
        'we will prevent the user from leaving the cell unless s/he entered numeric value for this cell
        e.Cancel = True
    End If
End Sub

More information about data validation is available here: http://www.telerik.com/help/winforms/gridview-editors-data-validation.html.

I hope this helps.

Regards,
Stefan
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Rawad
Top achievements
Rank 2
answered on 10 Jul 2014, 07:48 AM
hello stefan

nice solution, but why to let user enter alphanumeric while i just need integer,  it's better to not allow him from the beginning.
I tried the following code and it worked with me, but just first time and for the first letter, it allows alphanumeric.

    Private Sub radGridView1_CellBeginEdit(sender As Object, e As GridViewCellCancelEventArgs) Handles RadGridView1.CellBeginEdit
        Dim editor As RadTextBoxEditor = DirectCast(e.ActiveEditor, RadTextBoxEditor)
        If Not IsNothing(editor) Then
            Dim editorElement As RadTextBoxEditorElement = DirectCast(editor.EditorElement, RadTextBoxEditorElement)
            AddHandler editorElement.KeyPress, AddressOf KeyPresses
        End If
    End Sub

    Private Sub KeyPresses(sender As Object, e As KeyPressEventArgs)
        If Asc(e.KeyChar) <> 8 Then
            If ((Asc(e.KeyChar) < 48 Or Asc(e.KeyChar) > 57) And Asc(e.KeyChar) <> 46) Then
                e.Handled = True
            End If
        End If
    End Sub

Any idea ?
0
Stefan
Telerik team
answered on 11 Jul 2014, 06:46 AM
Hello Rawad,

Here is how your code might look like:
Private Sub radGridView1_CellBeginEdit(sender As Object, e As GridViewCellCancelEventArgs)
    Dim editor As RadTextBoxEditor = DirectCast(e.ActiveEditor, RadTextBoxEditor)
    If (editor IsNot Nothing) Then
        Dim editorElement As RadTextBoxEditorElement = DirectCast(editor.EditorElement, RadTextBoxEditorElement)
        RemoveHandler editorElement.KeyPress, AddressOf KeyPresses
        AddHandler editorElement.KeyPress, AddressOf KeyPresses
    End If
End Sub
 
Private Sub KeyPresses(sender As Object, e As KeyPressEventArgs)
    If Not Char.IsNumber(e.KeyChar) Then
        e.Handled = True
    End If
End Sub

It is important that you remove the handler prior adding it, as editor are being reused in the grid and this way you will avoid multiple subscriptions.

I hope that the provided information addresses your question.

Regards,
Stefan
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
GridView
Asked by
Gilberth
Top achievements
Rank 1
Answers by
Gilberth
Top achievements
Rank 1
Jack
Telerik team
Vassil Petev
Telerik team
Rawad
Top achievements
Rank 2
Stefan
Telerik team
Share this question
or