Results 1 to 5 of 5

Thread: Exclude field from view of Datagrid

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2001
    Location
    USA
    Posts
    1,026

    Exclude field from view of Datagrid

    How do I exclude a field in a RS from being shown in my datagrid?

    thnx,
    squirrelly1
    Now happily married and still crankin' away at the keyboard. Life is grand for a coder, no?

  2. #2
    Hyperactive Member tpfkanep's Avatar
    Join Date
    Jun 2002
    Location
    South Africa
    Posts
    272
    VB Code:
    1. dg.Columns(0).Width = 0   '1st column will not be displayed

  3. #3
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951
    Another thought is to direct your datasource to an SQL statement which doesn't include the excluded column.

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2001
    Location
    USA
    Posts
    1,026

    hmm...

    These are both wonderful ideas and would work great if my datagrid was setup a specific way everytime; however, it isn't. The user of my program has the ability to choose which fields he wants displayed in the datagrid and in which order, so I can not know where the field is located that I want excluded from viewing.

    Unless...

    Ok, how would I know which field is the last field shown in the datagrid?

    If I could do this, then I could just set that columns visible property to false...

    thanx,
    squirrelly1
    Now happily married and still crankin' away at the keyboard. Life is grand for a coder, no?

  5. #5
    Fanatic Member
    Join Date
    Aug 2001
    Location
    Connecticut
    Posts
    855
    The column captions and positions can be determined:
    for i = 0 to datagrid1.Columns.Count - 1
    position = i
    caption = datagrid1.Columns(i).Caption
    next i

    Similarly the fields in the underlying recordset
    for i = 0 to rs.Fields.Count - 1
    position = i
    name= rs.Fields(i).Name
    next i
    VB 6.0, Access, Sql server, Asp

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