[RESOLVED] Can I use hidden data ina DataGridView
Hello,
I am pretty new to DataGridView and I have a question. I managed to display the content of a database in a DGV and I've hidden the column ID which is the Index of my database.
Now, this Index is not in order from 1 to 10 for example. It is something like 1,3,6,12,22, etc... It changes during the editing of the database.
I don't need this number to be shown in my DGV but I need to know it's value when I click on a row.
So how can I do that? I found the way to display the row index or the contents of a certain cell but I didn't find this specific task.
The ideea is that, based on that index, I will display some related data on my form.
Also, I need to know if I can filter my data in a DGV. For example I don't want items from the database that contain a specific text to be shown.
Thx
Re: Can I use hidden data ina DataGridView
Assuming that you've hidden it by setting the column .Visible property to false, it hasn't gone anywhere. Its cells are still available using the usual index or name. If it was DGV.Columns(0) when you hid it, it's still DGV.Columns(0).
To filter a table in Datagridview ...
vb.net Code:
Dim dv As New DataView(DBSet.Tables(0))
dv.RowFilter = "CText <> 'some text'" ' shows all rows in which the CText column value isn't "some text"
DataGridView1.DataSource = dv
Re: Can I use hidden data ina DataGridView
Thank you dunfiddlin. It works that way.
First I have hidden my ID column in design mode and that's why it didn't work. Now I did it at runtime and it works just fine.
Cheers !