Results 1 to 4 of 4

Thread: [2005] Datagridview column visibility

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2006
    Posts
    54

    [2005] Datagridview column visibility

    Hello,

    I have a problem with a datagridview. In the datagrid view I have the primary key and foriegn key values that are inserted into it when the rowsadded event is fired. This works great except for the fact that I do not want my users to see the pk/fk values, and would like to not show them at all. If I set the visibility property to false, the values are not set, and throws an exception when they try and save.

    I tried looking into the mappingtype property but have been unable to solve the problem.

    How can I hide the columns but still have their values correctly stored?


    Thanks,
    Chris

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: [2005] Datagridview column visibility

    YourDataGridView.Columns(your_col_index).Visible = True / False as needed.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3
    Member
    Join Date
    Apr 2006
    Posts
    48

    Talking Re: [2005] Datagridview column visibility

    I also have found that this works:

    VB Code:
    1. 'Hide the column and attach dataset's DefaultView to the datagrid control
    2. DSBinData.Tables(0).Columns(7).ColumnMapping = MappingType.Hidden

    Where '0' is the index of which table you are using and '7' is which column number you are hiding. Hope this helps!

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] Datagridview column visibility

    You shouldn't use the ColumnMapping property of a DataColumn to hide a DataGridView column because that is not it's purpose. It has that effect but that is not its primary purpose so it has other implications as well.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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