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. how made datagrid auto resize column width to fix data length

how made datagrid auto resize column width to fix data length

Scheduled Pinned Locked Moved C#
helpquestion
3 Posts 3 Posters 1 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.
  • Z Offline
    Z Offline
    zeroonea
    wrote on last edited by
    #1

    how made datagrid auto resize column width to fix data length?? thanks

    M 1 Reply Last reply
    0
    • Z zeroonea

      how made datagrid auto resize column width to fix data length?? thanks

      M Offline
      M Offline
      Manoj Kumar Rai
      wrote on last edited by
      #2

      Hi, First, set the property "AutoSizeMode" to "NotSet" for the column. Then set the "width" to desired length. Manoj

      U 1 Reply Last reply
      0
      • M Manoj Kumar Rai

        Hi, First, set the property "AutoSizeMode" to "NotSet" for the column. Then set the "width" to desired length. Manoj

        U Offline
        U Offline
        User 7420507
        wrote on last edited by
        #3

        What I want the datagrid to do, is to auto-resize. It does that already when something longer is inserted into the datagrid. But it does not shrink, when something shorter is inserted from the datasource. I would prefer to let the framework handle the sizing.. I really do not want to program this - since this datagrid is one among many with this problem. It's pretty standard behaviour to resize columns according to their content. Why is it that the column width does rezise for strings which are longer, but does not resize for strings which are shorter. Sounds to me like I have to reset the width to standard widths each time I instantiate the datasource? Hm...

        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