CellValidating event question

10 posts, 1 answers
  1. shortie
    shortie avatar
    23 posts
    Member since:
    Jul 2008

    Posted 26 Aug 2009 Link to this post

    Hello,

    We need help in the following issues:

    1. When user inputs an invalid value for a cell, we can use ErrorText to show an error message in the RowHeaderColumn. Normally, the ErrorText will be cleared after the user corrects the value. Sometimes the user will just press Esc key to cancel the input value, in this case the CellValidating event won't get fired and the ErrorText will remain shown on the RowHeaderColumn. This behavior will make the user feel confused.

    2. We often have many columns to be shown in the grid and the user can use horizontal scroll bar to scroll to the region (s)he likes. When the user scrolls to the right, the ErrorText icon will still show up when a cell receives invalid value. But there is no ErrorText tooltip when the user moves the mouse over the ErrorText icon.

    3. We use HtmlViewDefine to arrange the columns in 2-row display. In this case, the row indicator and the columns will overlap with each other when the user scrolls the grid horizontally. And the ErrorText tooltip won't be shown as we described in the 2nd issues.

    Thanks in advance.

    BR/shortie

  2. Answer
    Jack
    Admin
    Jack avatar
    2333 posts

    Posted 01 Sep 2009 Link to this post

    Hi ChunChang,

    Regarding your questions:

    1. CellValidating event occurs only when a cell value is changed. In case when Esc is pressed, the value remains the same and no validation is needed. However, you can handle CellEndEdit event in this case and reset the ErrorText property.

    2. I confirm that this is an issue. Thank you for reporting it. We will address it in our upcoming release. I have updated your Telerik points for this bug report.

    3. This is a theme issue. You can work around it by using the ViewCellFormatting event:

    ((GridTableElement)this.radGridView1.GridElement).RowHeaderColumnWidth = 40; 
     
    void radGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e) 
        if (e.CellElement is GridRowHeaderCellElement && e.CellElement.RowElement is GridDataRowElement) 
        { 
            e.CellElement.DrawFill = true
            e.CellElement.GradientStyle = GradientStyles.Solid; 
            e.CellElement.BackColor = Color.White; 
            e.CellElement.ZIndex = 1000; 
        } 

    I hope this helps. If you need further assistance, I will be glad to help.

    Regards,
    Jack
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. NORIS
    NORIS avatar
    29 posts
    Member since:
    Jun 2009

    Posted 24 Sep 2009 Link to this post

    Hello Jack,
    Regarding:  1. CellValidating event occurs only when a cell value is changed. In case when Esc is pressed, the value remains the same and no validation is needed. However, you can handle CellEndEdit event in this case and reset the ErrorText property.

    I am doing an Add New Row.  The first two columns can not be null.  If no text is entered in the these columns the CellEndEdit is not fired, and obviously as you stated, the CellValidating is not either.  Even if I click in the cells and click out the CellEndEdit is not fired, so I am unable to update the ErrorText.  The grid allows the row to be added into the grid w/o text in these two columns.  Since I am using the DataSource as SQL data table It will get a data error when I try to update.
    How do I not allow them not to leave the new row unless there is text in the first two columns?
    If code is provided, please use VB.
    Thank you.

    After more testing I wanted to let you know that on the new row the DataError is fired if I click in a cell that can not be null.  If I do not enter the cell that can not be null the DataError is not fired.
  5. Jack
    Admin
    Jack avatar
    2333 posts

    Posted 26 Sep 2009 Link to this post

    Hi NORIS,

    This exception should not appear when using our latest release - Q2 2009 SP1. Could you please confirm that you are using this version? You can use RowValidating event to validate new rows. Here is a sample:

    void radGridView1_RowValidating(object sender, RowValidatingEventArgs e) 
        GridViewNewRowInfo newRow = e.Row as GridViewNewRowInfo; 
        if (newRow != null && newRow.DataRowInfo != null
        { 
            if (((GridViewDataColumn)this.radGridView1.CurrentColumn).UniqueName == "Column0"
            { 
                if (this.radGridView1.ActiveEditor.Value == DBNull.Value) 
                { 
                    e.Cancel = true
                } 
            } 
            else if (newRow.DataRowInfo.Cells[0].Value == DBNull.Value) 
            { 
                e.Cancel = true
            } 
        } 

    Here, we access new row cell values by using the DataRowInfo property, which contains the row that is being added. However, when there is an active editor, its value is not yet saved and you should use ActiveEditor property to get the actual value. I admit that this is a little unintuitive and we will improve our API in one of our upcoming releases.

    If you need further assistance, please write me back.

    Greetings,
    Jack
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  6. NORIS
    NORIS avatar
    29 posts
    Member since:
    Jun 2009

    Posted 29 Sep 2009 Link to this post

    Hi Jack,
    Yes, I  am using Q2 2009 SP1.
    This issue was answered by you in Support Ticket threadid=245874.
    Thank you.
  7. Jack
    Admin
    Jack avatar
    2333 posts

    Posted 30 Sep 2009 Link to this post

    Hi NORIS,

    I am glad to hear that. If you have any other questions, feel free to contact me.

    All the best,
    Jack
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  8. Subh
    Subh avatar
    8 posts
    Member since:
    Sep 2009

    Posted 05 Oct 2009 Link to this post

    Hi,
        How can the ErrorText be set at the cell level? The ErrorText property is missing at the cell level.

    Thanks in Advance

    Subha
  9. Jack
    Admin
    Jack avatar
    2333 posts

    Posted 07 Oct 2009 Link to this post

    Hello Subh,

    ErrorText is related to GridViewDataRowInfo and it can't be set at a cell level. However, you can use CellValidating or CurrentCellChanged events to update its value. Please, don't hesitate to write me if you have further questions.

    Best wishes,
    Jack
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  10. Ayman
    Ayman avatar
    3 posts
    Member since:
    Jun 2013

    Posted 18 Jun 2013 Link to this post

    hi
    What is the event fired when esc button pressed twice in rad gridview in winforms
    and
    Is there a away to check if the first row of the grid (row index [-1]) has a data in its cells
    and still not entered to new row

    thanks
  11. Anton
    Admin
    Anton avatar
    167 posts

    Posted 21 Jun 2013 Link to this post

    Hello Ayman,

    Thank you for writing.

    The event that is fired is when you press two times Esc button is KeyPress. However, if RadGridView is in edit mode on first key press, the CellEndEdit event will be fired and on the second key press the KeyPress event will be fired.

    As to your second question, I am not sure that I fully understand your scenario following the provided information. Please open a new support ticket and send us a sample application that demonstrates the case and I will be glad to help further.

    I am looking forward to your reply.

    Regards,
    Anton
    Telerik
    RadChart for WinForms is obsolete. Now what?
Back to Top
UI for WinForms is Visual Studio 2017 Ready