Tabcontrol中带有Checkboxcolumn的DataGridView

时间:2014-06-06 10:03:03

标签: vb.net visual-studio-2012 datagridview sql-server-2012

我有1个tabcontrol,有3个页面。每个页面包含3个不同的数据网格,它连接到sql服务器表,如DGV1,DGV2,DGV3 ..我在这些数据网格中有一个复选框列...我想取消选中一次全部解决所有三个数据网格...现在我的代码只检查当前的标签页...我需要知道有任何方法可以一次检查和取消选中所有...请帮帮我... < / p>

Private Sub checkdgv()
    For Each row As DataGridViewRow In DGV1.Rows
        row.Cells("sel1").Value = True
         TabControl1.SelectedTab =[tabcontrol1 for DGV1]
    Next
    For Each row As DataGridViewRow In DGV2.Rows
        row.Cells("sel2").Value = True
         TabControl1.SelectedTab =[[&tabcontrol1&] for DGV2]
    Next
    For Each row As DataGridViewRow In DGV3.Rows
        row.Cells("sel3").Value = True
         TabControl1.SelectedTab =[[tabcontrol1] for DGV3]
    Next

End Sub


Private Sub uncheckdgv()

    For Each row As DataGridViewRow In DGV1.Rows
        row.Cells("sel1").Value = False
    Next
    For Each row As DataGridViewRow In DGV2.Rows
        row.Cells("sel2").Value = False
    Next
    For Each row As DataGridViewRow In DGV3.Rows
        row.Cells("sel3").Value = False
    Next

End Sub

2 个答案:

答案 0 :(得分:0)

也许尝试将焦点设置在每个标签上,即:

FOR EACH row as DataGridViewRow In DGV1.Rows
    row.Cells("sel1").Value = False
TabControl1.SelectedTab = [tabcontrol for DGV2]
FOR EACH row as DataGridViewRow In DGV2.Rows
    row.Cells("sel2").Value = False

......等等。

答案 1 :(得分:0)

使用tabcontrol.SelectTab(1)函数将焦点移动到您想要工作的选项卡上。这对我有所帮助