How do I update a DataGridView when I change the other?

0

I have a DataGridView called gridProfissional that lists all the professionals that I have registered in a table.

I have another DataGridView called gridAgenda which lists the days that the professional attends.

I have a function that works correctly:

private void preencheGridAgenda()
{
    List<datum> listaData = new List<datum>();
    int idAgenda = Convert.ToInt32(gridProfissional.CurrentRow.Cells[0].Value.ToString());
    listaData = modelOff.data.Where(p => p.idAgenda.Equals(idAgenda)).ToList();
    gridData.DataSource = listaData;
    gridData.Select();
}

My intention is this: when selecting a line in gridProfissional , call the function preencherGridAgenda and update the gridAgenda.

In the event Scroll of gridProfissional I'm calling the function preencherGridAgenda , however, I select any line of my gridProfissional and the function is not called.

I'm using the wrong event ( Scroll )? Do you have another event for that?

    
asked by anonymous 30.06.2017 / 16:29

1 answer

1

The best way to do this is by using the SelectionChanged of DataGridView

    
30.06.2017 / 16:48