How to get the selected item

0

Hello, I'd like some help,

I'm using the DEVEXPRESS framework. I have a form with a GridControl, in this GridControl I have a DoubleClick event. When I click the selected line I want to get only the ID of the line. Using a normal grid I make this code to achieve:

private void gvDados_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0)
            {
                this.codigo = Convert.ToInt32(gvDados.Rows[e.RowIndex].Cells[0].Value);
                this.Close();
            }
        }

In this code I get the ID of the row I clicked, but when I use the DEVEXPRESSS GridControl component, there is no evolving CellDoubleClick, only the DoubleClick event. I've tried several things, but no success in getting the ID of the selected line.

If someone helps, thank

    
asked by anonymous 10.03.2018 / 18:54

1 answer

1

Good night, use the following code to get the value of the grid in the selected row. gvDados.gettext (columnID, grid.activerow) The id column is always the same, the line is the active line at the moment.

In your line you have to put the correct column that can not be 0. But the one defined for id. If it is 1a from the grid it is 1. this.codigo = Convert.ToInt32 (gvDados.Rows [e.RowIndex] .Cells [1] .Value);

    
10.03.2018 / 21:15