Results 1 to 3 of 3

Thread: [RESOLVED] Can I use hidden data ina DataGridView

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2012
    Posts
    221

    Resolved [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

  2. #2
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    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:
    1. Dim dv As New DataView(DBSet.Tables(0))
    2.         dv.RowFilter = "CText <> 'some text'" ' shows all rows in which the CText column value isn't "some text"
    3.         DataGridView1.DataSource = dv
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Sep 2012
    Posts
    221

    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 !

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width