Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In WinForms, how can I create a delete button in a DevExpress GridControl?

I'm trying to create a delete button at the right of every row in a DevExpress GridControl, like this:

enter image description here

What I've done is added another column and set its ColumnEdit property to an instance of RepositoryItemButtonEdit. I handle the ButtonClick event, to delete a row.

I can determine which row I'm on from this code:

myGridView.GetRow(myGridView.FocusedRowHandle);

Because I don't want a text editor on my button, I set the TextEditStyle to HideTextEditor.

By default, the button shows an ellipsis.

To remove the ellipsis, I adjusted the Buttons property on the RepositoryItemButtonEdit. I set the Kind to Glyph and set the image to my X icon.

Unfortunately that seems to simply remove the button altogether.

Does anyone know a better way to do this, or a way to show a button with an image on it, in each grid row?

like image 904
Stephen Oberauer Avatar asked Dec 11 '12 10:12

Stephen Oberauer


People also ask

How do I add a button in GridControl DevExpress?

If you wish to show buttons in a special column, create an unbound column and RepositoryItemButtonEdits with different buttons. Then, assign the repository items to grid cells conditionally in the GridView. CustomRowCellEdit event handler. To always show the buttons in a column, set the GridColumn.

How do I delete a row in Gridconpress DevExpress?

To delete rows, simply click the Delete button.

How do I add a row in GridControl DevExpress?

You cannot add a new row directly to your GridControl , since this is just a container for the views. However, if you're using a GridView inside your GridControl (or any other descendant of ColumnView), you can add a new row using AddNewRow() method. EDIT: You can access your view in a different way, of course.


1 Answers

I discovered that there is actually a delete button kind. So, I do everything as in the question, but instead of choosing the kind Glyph, I choose Delete, and I don't need to select an image.

like image 129
Stephen Oberauer Avatar answered Nov 01 '22 16:11

Stephen Oberauer