0

I'm working on a WindowsForm which has a TabControl with two TabPages. And I am trying to clear datagridview selection when I click on the 2nd tab, where the datagridview is. Howerver, if I first click on the 2nd TabPage it does not work. But, if I click back on 1st TabPage and then click back to 2nd TabPage again it works.

I tried to solve it by puttting the ClearSelection() on the form load but it didn't work.

Please help me out.

this is my code:

private void tcGrupoClientes_Selected(object sender, TabControlEventArgs e)
    {
        if (tcGrupoClientes.SelectedTab == tpConsultaGrupoClientes)
        {

            Logica.GrupoClientes objGrupoClientes = new Logica.GrupoClientes();
            dgvTodosLosGrupos.DataSource = objGrupoClientes.ConsultaMasiva();
            dgvTodosLosGrupos.ClearSelection(); 
        }
    }

Thanks in advance.

Errol Chaves Moya
  • 307
  • 2
  • 5
  • 20

1 Answers1

1

I solved the problem using "SelectedIndexChanged" event instead of "Selected" event

Errol Chaves Moya
  • 307
  • 2
  • 5
  • 20