Using DvExpress GridControl

-2

I'm developing an application using DevExpress, where the user clicks on a row in the GridControl, when that happens the data in that row is placed in some TextBox, the difficulty has been in figuring out the name of the event that I should use every time the user to click on a row, and how I look for this GridControl information.

    
asked by anonymous 26.10.2017 / 19:29

2 answers

0

The correct thing was to use GridView events instead of GridControl. So I used the FocusedRowChanged event so every time the user clicks on another Grid option will run the code.

With dtbTabela.Rows.Item(GridView1.GetFocusedDataSourceRowIndex)
        txtCampo.Text = .Item("dtcCampo")
        txtCampo2.Text = .Item("dtcCampo2")

End With

This code takes the index of the line that the user is clicking and then showing the value in two TextBoxes.

    
27.10.2017 / 19:30
1

Although confusing the question, I believe you want to get a value from a certain datagrid field and send it to a textbox, the event is called row.selected, I'll explain it best:

  

Suppose we have a table called GridClients and it contains 2 columns "id" and "name", to send the value of "id" to a textbox, you should use the following code:

idclient.Text = GridClientes.CurrentRow.Cells[0].Value.ToString();

The value of the cell is counted from 0, so ... if I have 2 fields, they are Cells [0] and Cells [1].

  

This code can be called inside the event of a button:

    private void button1_Click(object sender, EventArgs e)
    {

        idClient.Text = GridClientes.CurrentRow.Cells[0].Value.ToString();
    }
  

When a table cell is selected:

    private void GridClientes_CellEnter(object sender, DataGridViewCellEventArgs e)
    {
        idClient.Text = GridClientes.CurrentRow.Cells[0].Value.ToString();
    }
  

Or when an entire row of the table is selected (need to configure this feature):

    private void GridClientes_RowEnter(object sender, DataGridViewCellEventArgs e)
    {
        idClient.Text = GridClientes.CurrentRow.Cells[0].Value.ToString();
    }

I hope I have helped.

    
27.10.2017 / 19:53