BeginEditMode - like Excel

2 posts, 0 answers
  1. Paul
    Paul avatar
    35 posts
    Member since:
    Jan 2014

    Posted 12 Feb 2015 Link to this post

    I want to make editing in the RadGridView more familiar for users like using Excel.

    I currently have BeginEditMode set to BeginEditOnF2.  Unfortunately this goes into edit mode when:

    1. The user presses F2.
    2. You have a cell active (not in edit mode) and you click the same cell.
    3. You have a cell active (not in edit mode) and you click another cell.

    I want to only enter edit mode when:

    1. F2 is pressed.
    2. A cell is double-clicked.

    Can you give me info on how to do this please?

    Thanks

    Paul
  2. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 13 Feb 2015 Link to this post

    Hi Paul,

    Thank you for writing.

    RadGridView features the CellBeginEdit method, in which you can prevent an edit operation. This gives you great flexibility and you can customize the grid to get in edit mode as per your requirement. Here is an example covering your case:
    bool allowEdit = false;
     
    void radGridView1_CellDoubleClick(object sender, GridViewCellEventArgs e)
    {
        allowEdit = true;
    }
     
    void radGridView1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
    {
        if (e.KeyData == Keys.F2)
        {
            allowEdit = true;
        }
    }
     
    void radGridView1_CellBeginEdit(object sender, GridViewCellCancelEventArgs e)
    {
        if (allowEdit)
        {
            allowEdit = false;
            return;
        }
     
        e.Cancel = true;
    }

    I hope that you find this information useful. Should you have any other questions, do not hesitate to contact us.

    Regards,
    Stefan
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top