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. display custom column names in datagrid

display custom column names in datagrid

Scheduled Pinned Locked Moved C#
csharpcssdatabasehelptutorial
2 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.
  • I Offline
    I Offline
    itssuk
    wrote on last edited by
    #1

    hi i am working in a windows form in C#. i have a datagrid which displays values from the table in the database. i know how to assign custom headers or rather to change the column names. now suppose i change the ordering of the columns, how will can i set the column names respectively without keeping a track of their order. for eg. if my datagrid is such table name:software master softwareid softwaredesc remarks and i have given column names for them in the datagrid keeping their order into consideration as code description remarks now if the secondcolumn is to be shown as the third column,how can i change it so that even the custom column names are rearranged accordingly. plss help i have to create a common method which is to be called by more than form. in that case the columns of the grid are changing always.:confused::sigh: regards sukanya

    R 1 Reply Last reply
    0
    • I itssuk

      hi i am working in a windows form in C#. i have a datagrid which displays values from the table in the database. i know how to assign custom headers or rather to change the column names. now suppose i change the ordering of the columns, how will can i set the column names respectively without keeping a track of their order. for eg. if my datagrid is such table name:software master softwareid softwaredesc remarks and i have given column names for them in the datagrid keeping their order into consideration as code description remarks now if the secondcolumn is to be shown as the third column,how can i change it so that even the custom column names are rearranged accordingly. plss help i have to create a common method which is to be called by more than form. in that case the columns of the grid are changing always.:confused::sigh: regards sukanya

      R Offline
      R Offline
      Ravindra Sadaphule
      wrote on last edited by
      #2

      One way is to use aliases for columns in SQL query itself. e.g. the query can be SELECT Softwareid as Code, softwaredesc as description, remarks as remarks FROM SoftwareMaster Cheers Ravindra Sadaphule MCSD.NET

      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