隐藏数据网格视图中的行 [英] Hiding rows in datagrid view

查看:72
本文介绍了隐藏数据网格视图中的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个网格,一个显示处理另一个的订单,有待处理的订单;然而它似乎没有工作,因为网格中的所有数据都显示





I have got 2 grids, one shows orders which are processing the other, orders which are pending; however it doesn't seem to be working, as all of the data in the grid appears


foreach (DataGridViewRow dr in dataGridView4.Rows)
{
   int targetColumnIndex = 6;
   if (dr.Cells.Count > targetColumnIndex) // validate the index
      if (dr.Cells[targetColumnIndex].Value.ToString() == "Processing")
      {
         dr.Visible = false;
      }
}

foreach (DataGridViewRow dg in dataGridView1.Rows)
{
   int targetColumnIndex = 6;
   if (dg.Cells.Count > targetColumnIndex) // validate the index
      if (dg.Cells[targetColumnIndex].Value.ToString() == "Pending")
      {
         dg.Visible = false;
      }
}





我的尝试:



重写代码

更改处理/待定



What I have tried:

Re-writing code
change around processing / pending

推荐答案

会员13512434写道:
Member 13512434 wrote:



我是,



我现在收到此消息...



System.Windows.Forms.dll中发生未处理的System.InvalidOperationException类型异常



附加信息:与货币经理的位置相关联的行不能隐藏。


I am,

I'm now getting this message...

An unhandled exception of type 'System.InvalidOperationException' occurred in System.Windows.Forms.dll

Additional information: Row associated with the currency manager's position cannot be made invisible.





似乎您的datagridview与数据源绑定。好吧,我强烈建议过滤绑定源而不是隐藏datagridview行。



如果你还想隐藏行,你必须向bindingsource添加自定义属性。请参考以下内容:

c#如何使用DataSource隐藏DataGridView中的行 - Stack Overflow [ ^ ]

c# - 在DataGridView中隐藏行,绑定在我的项目中不起作用 - Stack溢出 [ ^ ]


这篇关于隐藏数据网格视图中的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆