【问题标题】:Hiding DGV Rows onload/TabPage Selection隐藏 DGV 行 onload/TabPage 选择
【发布时间】:2015-02-13 10:08:54
【问题描述】:

想知道为什么我无法在加载或选择标签页时成功运行此代码 -(将在按钮单击时运行)

For Each Row In DataGridView1.Rows

            If Not Row.index = 0 And Row.index < DataGridView1.Rows.Count - 1 Then

                If Not Row.Cells(6).Value = WhoIsIt Then
                    Row.Visible = False
                Else
                    Row.Visible = True
                End If

            Else

                If Not Row.Cells(6).Value = WhoIsIt And Row.index < DataGridView1.Rows.Count Then
                    Row.DefaultCellStyle.BackColor = Color.Black
                End If

            End If

        Next

背景:DGV 连接到访问表。我的目标是让它只显示在被检查的单元格中包含用户姓名首字母的行。

【问题讨论】:

    标签: vb.net winforms datagridview


    【解决方案1】:

    只需使用此代码

    for i as integer =0 to DataGridView1.Rows.Count - 1   
           if DataGridView1.Rows(i).Cells(6).Value <> WhoIsIt then  
              DataGridView1.Rows(i).visible=false  
           end if  
    next
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-05
      • 2010-10-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多