Hello everyone
I have a grid in which the user introduces info. By pressing Enter in the last column of the row he is modifying, I immediately open a new row for him to start a new line. In the image I send, you can see that a new row is available to be completed. But, if he leaves the Grid without completing it, this row gets deleted. All that works fine. My problem is, when he abandons the row by clicking on another row, say by clicking on row nº 7 (see image), because I go through the Grid scanning for incomplete rows to delete, it is as though the Grid loses the focus... I suppose I have to capture the index of the row he has clicked on before looking for empty rows to delete. Ideally, I would like row nº 7 to go in Edit Mode after I have erased the incomplete row... How do I do that? What events do I use? I hope you understand what I mean. Thanks.
Hello Mariela77,
If you know the row index in this case you would be able to achieve something closer to what you are looking for by using code snippet like the one below:
ultraGrid1.Focus(); ultraGrid1.Rows["Row Index Here"].Activate(); ultraGrid1.Rows["Row Index Here"].Cells["Desired Cell Index"].Activate(); ultraGrid1.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode);So after the emtpy row gets deleted, performing such code snippet will enter into edit mode the desired cell in the row which were clicked before.
Please feel free to let me know if you have any other questions with this matter.
Hello Danko
When exactly should I capture the index of the row the user has clicked on? I was trying BeforeRowDeactivates, AfterRowActivate, Click... But I am not successful with any of them...
Thanks
Hello Mariela,
I am still following this forum thread.
Please feel free to let me know if you need any other assistance with this matter.
Everything depends on the specific scenario that you are having. I have provided one possible way to achieve what you are looking for.
Another approach might be the following : Using the InitializeRow event, loop through the cells of the row, and if at least one cell is emtpy set the row's tag property to something different than null. Once you click in any cell, you would have again to iterate through all of the rows and delete the one that have its Tag property set like :
private void ultraGrid1_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e) { foreach (UltraGridCell cell in e.Row.Cells) { if (cell.Value == DBNull.Value) { e.Row.Tag = "Something"; } } } private void ultraGrid1_AfterEnterEditMode(object sender, EventArgs e) { for (int i = 0; i < ultraGrid1.Rows.Count;i++ ) { if (ultraGrid1.Rows[i].Tag != null) { ultraGrid1.Rows[i].Delete(); } } } private void ultraGrid1_BeforeRowsDeleted(object sender, BeforeRowsDeletedEventArgs e) { e.DisplayPromptMsg = false; }
Please feel free to let us know if you have any other questions with this matter.