Click here to Skip to main content
15,072,422 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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!
Updated 7-Aug-13 9:17am

1 solution

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'd still set it to the DataTable object, but since the DataTable's DataView will have the filter, so will the you could do something like this:

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

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900