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. C#
  4. Hiding a DataColumn in a DataGrid

Hiding a DataColumn in a DataGrid

Scheduled Pinned Locked Moved C#
question
3 Posts 3 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.
  • O Offline
    O Offline
    obelisk29
    wrote on last edited by
    #1

    How do I hide a DataColumn in a Datagrid? TIA ------------------ I'm naked under my clothes...

    K L 2 Replies Last reply
    0
    • O obelisk29

      How do I hide a DataColumn in a Datagrid? TIA ------------------ I'm naked under my clothes...

      K Offline
      K Offline
      Kodanda Pani
      wrote on last edited by
      #2

      Hi TIA, You can hide the colum by setting the width to 0. DataGridTableStyle tblstyle = new DataGridTableStyle(); tblstyle.MappingName = dataGrid1.DataMember; //table name dataGrid1.TableStyles.Add(tblstyle ); dataGrid1.TableStyles[0].GridColumnStyles["XX"].Width = 0; where XX is your colum number. Guess this will help you. Thanks and Regards SGS

      1 Reply Last reply
      0
      • O obelisk29

        How do I hide a DataColumn in a Datagrid? TIA ------------------ I'm naked under my clothes...

        L Offline
        L Offline
        Luis Alonso Ramos
        wrote on last edited by
        #3

        The other reply suggested using table dataatyles. If I remember correctly, if you don't have a table style, all columns in the data table are shown. If you add a table style to the data grid, you have to create a table column style for every column you want to display. So if you have a data table with 7 columns, and only add 5 table column styles, you only get 5 columns in the grid. But as the other reply suggested, add a table column style for the hidden cell and set its width to 0, but that might allow the user to resize if he clicks at the right place. -- LuisR


        Luis Alonso Ramos Intelectix - Chihuahua, Mexico Not much here: My CP Blog!

        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