首页 > Windows开发 > 详细

章鱼哥出品—VB.NET DataGridView绑定数据源 "与货币管理器的位置关联的行不能设置为不可见" 问题的解决

时间:2014-10-15 15:42:27      阅读:657      评论:0      收藏:0      [点我收藏+]
DtaGridView绑定数据源后,如果想让数据条件显示的话,直接使用  My_Row.Visible = False就会出错,错误类型是 "与货币管理器的位置关联的行不能设置为不可见" ,如果你遇到这样的问题,那么可以参考一下的代码。
   Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Try
            Dim cm As CurrencyManager = BindingContext(DataGridView1.DataSource)
            cm.SuspendBinding() '将绑定挂起
            For Each My_Row As DataGridViewRow In DataGridView1.Rows
                If Trim(My_Row.Cells(0).Value) = "小明" Then
                    My_Row.Visible = True
                ElseIf Not My_Row.Cells(0).Value = "" Then '忽略最后一行空行
                    My_Row.Visible = False
                End If
            Next
            cm.ResumeBinding() '恢复绑定
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

        'Button1.Enabled = True
        'Button2.Enabled = False
    End Sub



章鱼哥出品—VB.NET DataGridView绑定数据源 "与货币管理器的位置关联的行不能设置为不可见" 问题的解决

原文:http://blog.csdn.net/zhangyubishoulin/article/details/40110051

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!