Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Hide a datagrid column in VB .NET 2003

Hide a datagrid column in VB .NET 2003

Scheduled Pinned Locked Moved Visual Basic
csharpquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hlortie
    wrote on last edited by
    #1

    Hi! I have a datagrid filled with a dataset table. I would like to know if it is possible to hide a one of the datagrid column? thanks! Hugo

    J 1 Reply Last reply
    0
    • H hlortie

      Hi! I have a datagrid filled with a dataset table. I would like to know if it is possible to hide a one of the datagrid column? thanks! Hugo

      J Offline
      J Offline
      jsampsonPC
      wrote on last edited by
      #2

      Hey hlortie, To answer your question, you want to access the .Visible property of the DataGridView.Columns("ColumnName") object. So if your dataGridView is called "dgvProducts", and your column is called "Amount", you could effectively hide it by writing the following: dgvProducts.Columns("Amount").Visible = False Hope that helps!

      Jonathan Sampson www.SampsonResume.com

      H 1 Reply Last reply
      0
      • J jsampsonPC

        Hey hlortie, To answer your question, you want to access the .Visible property of the DataGridView.Columns("ColumnName") object. So if your dataGridView is called "dgvProducts", and your column is called "Amount", you could effectively hide it by writing the following: dgvProducts.Columns("Amount").Visible = False Hope that helps!

        Jonathan Sampson www.SampsonResume.com

        H Offline
        H Offline
        hlortie
        wrote on last edited by
        #3

        I've found the way to do it: 'Assign style to datagrid tStyle.MappingName = datagrid.DataMember datagrid.TableStyles.Add(tStyle) 'Hide column datagrid.TableStyles("Table_name").GridColumnStyles("column_name").Width = 0

        J 1 Reply Last reply
        0
        • H hlortie

          I've found the way to do it: 'Assign style to datagrid tStyle.MappingName = datagrid.DataMember datagrid.TableStyles.Add(tStyle) 'Hide column datagrid.TableStyles("Table_name").GridColumnStyles("column_name").Width = 0

          J Offline
          J Offline
          jsampsonPC
          wrote on last edited by
          #4

          The way I told you will work as well, and is actually the way you're supposed to do it. Your way allows people the option to widen the width, and see the information you were hiding. May I suggest you hide the column if you sincerely want to hide it. Setting the width to 0 is not hiding it.

          Jonathan Sampson www.SampsonResume.com

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups