How to pick up the selected item

Asked

Viewed 591 times

0

Hi, I’d like a hand,

I’m using the DEVEXPRESS framework. I have a form with a Gridcontrol, In this Gridcontrol I have a Doubleclick event. When I click on the selected line I want to take only the ID line. Using a normal grid I do this code to get:

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 can get the ID of the line I clicked, but when I use the component of DEVEXPRESSS Gridcontrol, there is no evendo Celldoubleclick, only the Doubleclick event. I’ve tried several things, but without success to get the ID of the selected line.

If anyone helps, thank you

  • has to be with double click? If I’m not mistaken, the dev grid control does not accept double click on Rows

  • does not have a function called Getfocusedrow() ? Usually it returns the object that is on the line.

2 answers

0

Hello,

Using the Devexpress "Doubleclick" event would be almost the same.

private void grdView1_DoubleClick(object sender, EventArgs e)
    {
        int index = grdView1.GetFocusedDataSourceRowIndex();
    }

0

Good evening, use the following code to get the grid value on the selected line:

 gvDados.gettext(colunaID,grelha.activerow)

The id column is always the same, the line is currently active.

In your row you have to put the correct column which cannot be 0. But the one set to id. If it is the 1a of the grid is 1:

this.codigo = Convert.ToInt32(gvDados.Rows[e.RowIndex].Cells[1].Value);
  • Good evening Daniel, I am wearing the following event private void gvDados_DoubleClick(object sender, EventArgs e)
 {
 
 } Because Devexpress Gridcontrol doesn’t have the Celldoubleclick event, so I can’t use the following code I mentioned above.

  • See if the following code helps: private void gvDados_DoubleClick(Object eventSender, Eventargs eventargs) { int Index = Array.Indexof(this.gvDados,eventSender); if (Index >= 0) { gvDados.Gettext(Colunaid, Grid.Activerow); } } I tested with the devExpress grid in VS

Browser other questions tagged

You are not signed in. Login or sign up in order to post.