我有一个 DataGridView
,我设置了它的 DataSource
:
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;
但我无法做到这一点。相反,抛出了以下错误信息的异常:
无法使与货币管理器位置相关联的行不可见
我怀疑原因与设置 DataSource
有关,但是为什么呢?
MyGrid.Rows[e.RowIndex].Visible = false;
放在哪里?奇怪的是,如果你使用任意的index
,比如0
、1
等,它可以成功隐藏行。 - King King