无法设置数据网格视图的行可见假 [英] Unable To set row visible false of a datagridview
本文介绍了无法设置数据网格视图的行可见假的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个 DataGridView
,我在其中设置了 DataSource
:
I have a DataGridView
where I set DataSource
:
taskerEntities te = new taskerEntities();
var OMsMasterDescriptiveIndicators = te.MyTable.Select(x => new lccls {Id = x.Id, name = x.name }).ToList();
MyGrid.DataSource = OMsMasterDescriptiveIndicators;
使用我的 class lccls
作为
public class lccls
{
public string Id { get; set; }
public Nullable<decimal> name { get; set; }
}
在某个事件中,我想让当前行不可见:
At a certain event I want to make the current row invisible:
MyGrid.Rows[5].Visible = false;
但我无法做到这一点.而是抛出异常并显示以下错误消息:
But I am unable to do this. Instead an exception is thrown with the following error message:
不能制作与货币经理职位相关的行隐形
Row associated with the currency manager's position cannot be made invisible
我怀疑原因与设置DataSource
有关,但为什么呢?
I suspect the reason is related to setting DataSource
, but why?
推荐答案
搜索了很多,我得到了 解决方案
After searching a lot, I got the solution
CurrencyManager currencyManager1 = (CurrencyManager)BindingContext[MyGrid.DataSource];
currencyManager1.SuspendBinding();
MyGrid.Rows[5].Visible = false;
currencyManager1.ResumeBinding();
这篇关于无法设置数据网格视图的行可见假的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文