数据网格过滤器错误 [英] Data grid filter error

查看:108
本文介绍了数据网格过滤器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我为数据网格中的过滤器值编写了以下代码

Hi,

I wrote following code for filter values in data gride

string wordsForSearch = cmbWords.SelectedItem.ToString();
            string index1 = cmbCountLowerLimit.SelectedItem.ToString();

            for (int i = 0; i < dgvFilter.RowCount; ++i)
            {

                string a = dgvFilter.Rows[i].Cells[wordsForSearch].Value.ToString().ToLower();

                while (i > 0 )
                {
                    dgvFilter.Rows.RemoveAt(i);
                }
   
            }



它给出了所提供的行索引超出范围.
参数名称:index
异常,如果可以提供示例代码,请帮我.它将非常有用.



It gives Row index provided is out of range.
Parameter name: index
exception please help me if you can give sample code it will be very useful.

推荐答案

while (i < 0 )

嘿哥们,根据for loop,您认为这意味着什么?代码有可能永远运行吗?
while (i < 0 )

Hey buddy, what do you think that means in the light of for loop? Is there any chance that code running ever?


您尝试调试吗?

看起来,for循环已启动,可以说1到5,但是在循环中,您删除了行,因此dataview中的实际行数减少了.注释删除部分并检查,然后尝试放入所需的逻辑.
Did you try debugging?

Looks like, the for loop was initiated for let say 1 to 5 but inside loop you remove the rows and thus the acutal number of rows in dataview are less. Comment the remove part and check and then try to put the logic needed.


这篇关于数据网格过滤器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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