Reputation: 377
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.
Upvotes: 0
Views: 383
Reputation: 377
I solved the problem using "SelectedIndexChanged" event instead of "Selected" event
Upvotes: 1