无法设置datagridview的行可见的false [英] Unable To set row visible false of a datagridview
本文介绍了无法设置datagridview的行可见的false的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个 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;
与我的类lccls
as
public class lccls
{
public string Id { get; set; }
public Nullable<decimal> name { get; set; }
}
在某个事件我想使当前行不可见: p>
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:
与货币经理的头寸关联的行不能被作为
invisible
Row associated with the currency manager's position cannot be made invisible
我怀疑原因与设置 DataSource
有关,但为什么? >
I suspect the reason is related to setting DataSource
, but why?
推荐答案
搜索很多,我得到了解决方案
CurrencyManager currencyManager1 = (CurrencyManager)BindingContext[MyGrid.DataSource];
currencyManager1.SuspendBinding();
MyGrid.Rows[5].Visible = false;
currencyManager1.ResumeBinding();
这篇关于无法设置datagridview的行可见的false的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文