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

BeginEditMode - like Excel

1 Answer 62 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 12 Feb 2015, 08:57 PM
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

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 13 Feb 2015, 08:19 AM
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.

 
Tags
GridView
Asked by
Paul
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or