Hello guys,I have an UltraGrid with 5 columns and several rows.I'd like to know if there is an option somewhere in UltraGrid properties to add a button or an icon to delete the row selected by the user.
Or if I have to create an UltraButton implemented in my class.I'm asking this because there is an option for adding a new row and as a rookie, I was wondering if there is the same thing for the deletion.Thanks a lot !
Hello Antony,
Thank you for your feedback.
I am glad to hear that you have solved your issue. Please note one other possible solution to make click on the cell to select the row is to set CellClickAction of the grid to RowSelect.
More about CellClickAction property you may find by following the next link http://help.infragistics.com/Help/Doc/WinForms/2015.2/CLR4.0/html/Infragistics4.Win.UltraWinGrid.v15.2~Infragistics.Win.UltraWinGrid.UltraGridOverride~CellClickAction.html.
Thank you for using Infragistics Components.
Hello Milko,Thank you for you answer.I've created a button to delete the current row(s). Here's the code about it :
private void deleteButton_Click(object sender, EventArgs e) { // Check if there are any selected rows. if (this.UltraGridExcludes.Selected.Rows.Count > 0) { // Delete the selected rows by calling DeleteSelectedRows. this.UltraGridExcludes.DeleteSelectedRows(); } else { // Show a message if there are no selected rows. MessageBox.Show("There are no rows selected. Select rows first."); } }
But it does not work. It always returns me the messageBox. I tried Ctrl+clic, Ctrl+A, Ctrl+Shif+clic, double clic, ... to select a row but it still not pass into the if statement. Maybe I'm doing something wrong ?
Edit: I do not have the little column on the left to see the current row selected with the little black arrow. That's maybe why I have always 0 row selected when I take a look to the count() result.Edit 2: I add the colum for the row selection, and it's working, thank you Milko !
Thank you for posting in our forum.
Right now UltarGrid does not have such build in button. However if you need to implement such functionality you may add your own button. In the button click event handler call DeleteSelectedRows method of the grid. This will delete all currently selected rows in there are any.
One more point. When you call this method the grid will pop up a message asking the user for confirmation. You can suppress this message box either by using this overload of DeleteSelectedRows:
this.ultraGrid1.DeleteSelectedRows(false);
or by setting ShowDeleteRowsPrompt property of the DisplayLayout to false like this:
this.ultraGrid1.DisplayLayout.ShowDeleteRowsPrompt = false;
More about DeleteSelectedRows method you may find by following the next link http://help.infragistics.com/Help/Doc/WinForms/2015.2/CLR4.0/HTML/Infragistics4.Win.UltraWinGrid.v15.2~Infragistics.Win.UltraWinGrid.UltraGrid~DeleteSelectedRows().html.
Please let me know if you have any additional questions.