我有一个DataGridView,我在其中设置DataSource: taskerEntities te = new taskerEntities();var OMsMasterDescriptiveIndicators = te.MyTable.Select(x = new lccls {Id = x.Id, name = x.name }).ToList();MyGrid.DataSource = OMsMasterDescri
taskerEntities te = new taskerEntities(); var OMsMasterDescriptiveIndicators = te.MyTable.Select(x => new lccls {Id = x.Id, name = x.name }).ToList(); MyGrid.DataSource = OMsMasterDescriptiveIndicators;
和我的班级lccls一样
public class lccls { public string Id { get; set; } public Nullable<decimal> name { get; set; } }
在某个事件中,我想让当前行不可见:
MyGrid.Rows[5].Visible = false;
但我无法做到这一点.而是抛出异常,并显示以下错误消息:
Row associated with the currency manager’s position cannot be made
invisible
我怀疑原因与设置DataSource有关,但为什么呢?
经过大量搜索,我得到了 solutionCurrencyManager currencyManager1 = (CurrencyManager)BindingContext[MyGrid.DataSource]; currencyManager1.SuspendBinding(); MyGrid.Rows[5].Visible = false; currencyManager1.ResumeBinding();