zoukankan      html  css  js  c++  java
  • c# datagridview 设置某行不可见解决办法

    【前提】datagridview与数据库绑定,需要单独设置某行或者某个单元格不可见。

    【问题分析】直接用this.dataGridCiew1.Rows[0].Visible = false;不可行,会出现:与货币管理器的位置关联的行不能设置为不可见。这个问题。

    【问题原因】数据绑定问题,必须先将数据绑定挂起,才能实现设置某行不可见,然后再将数据绑定恢复。

    【解决方案】CurrencyManager:货币管理类

                     在CurrencyManager中有2个方法:SuspendBinding();——挂起数据绑定。ResumeBinding();——恢复数据绑定。

                     

                     CurrencyManager cm = (CurrencyManager)BindingContext[DataGirdView.DataSource];

                     cm.SuspendBinding(); 挂起数据绑定

                     .........

                     DataGridView.SelectedRows[0].Visible = false;

                     .........

                     cm.ResumeBinding(); 恢复数据绑定

    【参考链接】http://www.cnblogs.com/fanyf/archive/2012/03/01/2375574.html

  • 相关阅读:
    455. Assign Cookies
    [leetcode]Linked List Cycle
    *[topcoder]GooseTattarrattatDiv1
    [topcoder]FoxAndChess
    *[topcoder]TheTree
    *[topcoder]LittleElephantAndBalls
    *[topcoder]HexagonalBoard
    *[topcoder]AstronomicalRecords
    *[topcoder]LittleElephantAndIntervalsDiv1
    [topcoder]IncrementAndDoubling
  • 原文地址:https://www.cnblogs.com/SnowWKJ/p/3224621.html
Copyright © 2011-2022 走看看