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. How to resize column width of datagrid.

How to resize column width of datagrid.

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

    Hello, I am using datagrid to show my records. now column width is set by default. which could be resized but that doesn't look good presentation. so can anybody tell me how can I resize my datagrid column width. Thank you For ur support. Inpreet Singh

    M H 2 Replies Last reply
    0
    • I Inpreet Singh

      Hello, I am using datagrid to show my records. now column width is set by default. which could be resized but that doesn't look good presentation. so can anybody tell me how can I resize my datagrid column width. Thank you For ur support. Inpreet Singh

      M Offline
      M Offline
      Mazdak
      wrote on last edited by
      #2

      Search for DataGridColumnStyle class to find examples. Mazy "Man is different from animals in that he speculates, a high risk activity." - Edward Hoagland

      1 Reply Last reply
      0
      • I Inpreet Singh

        Hello, I am using datagrid to show my records. now column width is set by default. which could be resized but that doesn't look good presentation. so can anybody tell me how can I resize my datagrid column width. Thank you For ur support. Inpreet Singh

        H Offline
        H Offline
        Heath Stewart
        wrote on last edited by
        #3

        See the DataGrid.TableStyles Property[^] documentation in the .NET Framework SDK for a detailed review of how to explicitly define table and column styles. For instance, if you use a DataSet (and assign the DataGrid.DataMember to the appropriate table name within the DataSet) or DataTable for the DataGrid.DataSource property, you create a new DataGridTableStyle with the MappingName set to the table (you can also set it to specially formatted names for non-DataSet data sources, but see the documentation for more information). You then add DataGridColumnStyles to the table style that map to your column names. You can specify captions, column widths, string formats (for numbers, dates, etc.), and more. You can also define your own. The VS.NET DataGrid designer also does a great job of helping you if you assign your DataSet at design-time to the DataGrid.DataSource (using the DataSet to create an instance of some strongly-typed DataSet defined in your current or dependent project). Even without, click on the "..." button next to the TableStyles property and explore.

        Microsoft MVP, Visual C# My Articles

        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