如何使用vb.net中的RowFilter从datagridview中排除或修剪空白单元格 [英] How to exclude or trim blank cells from datagridview using RowFilter in vb.net

查看:538
本文介绍了如何使用vb.net中的RowFilter从datagridview中排除或修剪空白单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试找到一种方法,用于在导入时删除或修剪DataGridView中的空白单元格.我在网上发现了一些与数据源一起使用的行过滤器的信息.

现在,这就是我声明数据源的方式:

I''m trying to find a way to delete or trim blank cells in my DataGridView on import. I found a few things on-line about the row filter that works with the data source.

Right now this is how I''m declaring my data source:

DataGridView1.DataSource = DS.Tables(0).DefaultView


如果有人可以给我一些建议或告诉我如何使用行过滤器修剪空白单元格,我将不胜感激!


If anyone can give me some suggestions or tell me how to trim the blank cells with the row filter I would greatly appreciate it!

推荐答案

请参见
See MSDN article DataView.RowFilter Property[^]

To use it, you assign it a string that has something similar to the WHERE portion of an SQL statement. And you don''t need to set the DataSource to the DataView object...you''d still set it to the DataTable object, but since the DataTable''s DataView will have the filter, so will the grid...so you could do something like this:

DataGridView1.DataSource = DS.Tables(0)
DataGridView1.DataSource.DefaultView.RowFilter = "columnThatMightHaveBlanks<>''"


这篇关于如何使用vb.net中的RowFilter从datagridview中排除或修剪空白单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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