Hi,
I have a question regarding RadGridView. When I edit a cell in GridView and then click on a button (outside of gridview) immediately (i.e I don't click on another cell to exit edit mode), the Gridview is still edit mode. Please refer to the short video named "Without Using EndEdit()" to easily understand my point here.
In order to exit the edit mode, I try the following code:
Private Sub CustomGridView_LostFocus(sender As Object, e As EventArgs) Handles Me.LostFocus Me.EndEdit() End Sub
With this code, the gridview does exit the edit mode when I click on another button. But there is a problem with this method is that afterwards, I cannot edit the cell anymore. Please refer to the short video named "Using EndEdit()" to better understand the problem.
So my question here is, is there any way that I can exit edit mode when clicking on another button right after editing a cell?
Thank you for your help.
Best regards,
Tran
DataTable masterTable = new DataTable();
DataTable childTable = new DataTable();
public RadForm1()
{
InitializeComponent();
masterTable.Columns.Add("Id", typeof(int));
masterTable.Columns.Add("Name", typeof(string));
for (int i = 0; i < 3; i++)
{
masterTable.Rows.Add(i, "Row" + i);
}
childTable.Columns.Add("Id", typeof(int));
childTable.Columns.Add("ParentId", typeof(int));
childTable.Columns.Add("Title", typeof(string));
childTable.Columns.Add("Date", typeof(DateTime));
Random rand = new Random();
for (int i = 0; i < 20; i++)
{
childTable.Rows.Add(i, rand.Next(0, 3), "Child" + i, DateTime.Now.AddDays(i));
}
radGridView1.DataSource = masterTable;
radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
GridViewTemplate template = new GridViewTemplate();
template.DataSource = childTable;
template.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
radGridView1.MasterTemplate.Templates.Add(template);
GridViewRelation relation = new GridViewRelation(radGridView1.MasterTemplate);
relation.ChildTemplate = template;
relation.RelationName = "MasterChild";
relation.ParentColumnNames.Add("Id");
relation.ChildColumnNames.Add("ParentId");
radGridView1.Relations.Add(relation);
this.radGridView1.UserAddedRow+=radGridView1_UserAddedRow;
}
private void radGridView1_UserAddedRow(object sender, GridViewRowEventArgs e)
{
e.Row.IsExpanded = true;
this.radGridView1.CurrentRow = ((GridViewHierarchyRowInfo)e.Row).Views[0].TableAddNewRow;
this.radGridView1.CurrentColumn = this.radGridView1.MasterTemplate.Templates[0].Columns[0];
this.radGridView1.BeginEdit();
}
Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik
Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.
Hi.
I have two gridviews in a form: Master and Detail. I am trying to set the focus on Detail Grid when the Master grid UserAddedRow Event occurs, but, it doesn't work. The focus always stays in the Master grid. Is possible to do that in Telerik GridView?
I have logged it in our feedback portal by creating a public thread on your behalf. You can track its progress, subscribe for status changes and add your comments on the following link - feedback item.
I have also updated your Telerik points.
Currently, the possible solution that I can suggest is to call the EndEdit method in the Click event of the RadButtonElement in the ribbon:
Private Sub RadButtonElement1_Click(sender As Object, e As EventArgs)
Me.RadGridView1.EndEdit()
End Sub
I hope this information helps. If you need any further assistance please don't hesitate to contact me.
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik