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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. DataGrid Column Display

DataGrid Column Display

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

    Thank you for Soliant's suggestion using the DataTableMapping object. But I think the TableMapping function is just to map the data from source to datatable. It doesn't specify the order of the columns in the dataset, does it? I still can't figure out how I can display the data in my own way. It is still in alphabetical order from left to right. I've also tried using TableMapping property from the DataAdapter. Did I do something wrong? or miss anything? Please give me a little more detail about it. Thank you!

    A 1 Reply Last reply
    0
    • H hkl

      Thank you for Soliant's suggestion using the DataTableMapping object. But I think the TableMapping function is just to map the data from source to datatable. It doesn't specify the order of the columns in the dataset, does it? I still can't figure out how I can display the data in my own way. It is still in alphabetical order from left to right. I've also tried using TableMapping property from the DataAdapter. Did I do something wrong? or miss anything? Please give me a little more detail about it. Thank you!

      A Offline
      A Offline
      A Wegierski
      wrote on last edited by
      #2

      Very unusual case (I use Oracle, MSSQL and DB2). Try to define Your own fields in DataGrid: DataGridTextBoxColumn tc1,tc2; DataGridTableStyle ts; DataGrid myDataGrid; tc1 = new DataGridTextBoxColumn(); tc1.MappingName="myColumn1Name"; ... tc2 = new DataGridTextBoxColumn(); tc2.MappingName="myColumn2Name"; ... ts = new DataGridTableStyle() ts.MappingName = "myTableName"; ... ts.GridColumnStyles.AddRange(new DataGridColumnStyle[] { tc1,tc2 }); myDataGrid.TableStyles.AddRange(new DataGridTableStyle[]{ ts }); myDataGrid.DataSource = myTable ... Sincerely AW

      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