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. Set Column Width in Dynamic Table

Set Column Width in Dynamic Table

Scheduled Pinned Locked Moved C#
csharptutorial
3 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.
  • T Offline
    T Offline
    tantja
    wrote on last edited by
    #1

    I create a dynamic table using the code below (c#), but I couldn't figure out how to set the column width (in column3 comments). DataTable tbl; DataColumn col; tbl = new DataTable(); col = new DataColumn("column1"); tbl.Columns.Add(col); col = new DataColumn("column2"); tbl.Columns.Add(col); col = new DataColumn("column3 comments"); tbl.Columns.Add(col); tbl.AcceptChanges(); DataRow r; r = tbl.NewRow(); r["column1"] = "This is 1"; r["column2"] = "This is 2"; r["column3 comments"] = "Comments is really long & I need to set the width for this"; tbl.Rows.Add(r);

    P 1 Reply Last reply
    0
    • T tantja

      I create a dynamic table using the code below (c#), but I couldn't figure out how to set the column width (in column3 comments). DataTable tbl; DataColumn col; tbl = new DataTable(); col = new DataColumn("column1"); tbl.Columns.Add(col); col = new DataColumn("column2"); tbl.Columns.Add(col); col = new DataColumn("column3 comments"); tbl.Columns.Add(col); tbl.AcceptChanges(); DataRow r; r = tbl.NewRow(); r["column1"] = "This is 1"; r["column2"] = "This is 2"; r["column3 comments"] = "Comments is really long & I need to set the width for this"; tbl.Rows.Add(r);

      P Offline
      P Offline
      PIEBALDconsult
      wrote on last edited by
      #2

      Ummmm... I assume you mean when it's displayed somehow?

      T 1 Reply Last reply
      0
      • P PIEBALDconsult

        Ummmm... I assume you mean when it's displayed somehow?

        T Offline
        T Offline
        tantja
        wrote on last edited by
        #3

        yeh...when it display. i connect it to the datagrid, but i couldn't find a way to set the width of the column in there.

        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