Results 1 to 5 of 5

Thread: Datagridview AllowUserToResizeColumns not working

  1. #1

    Thread Starter
    Frenzied Member dolot's Avatar
    Join Date
    Nov 2007
    Location
    Ancient City, U.S.
    Posts
    1,254

    Datagridview AllowUserToResizeColumns not working


    I have some code written by another developer (no, really). The datagridview has the AllowUserToResizeColumns property set to true, but at runtime the grid will not allow column resizing. I've checked the code to see if the property is being set in code and I can't find anything. Is there some other grid property that, if set to a certain value, will disable column resizing?
    I always add to the reputation of those whose posts are helpful, and even occasionally to those whose posts aren't helpful but who obviously put forth a valiant effort. That is, when the system will allow it.
    My war with a browser-redirect trojan

  2. #2

    Thread Starter
    Frenzied Member dolot's Avatar
    Join Date
    Nov 2007
    Location
    Ancient City, U.S.
    Posts
    1,254

    Re: Datagridview AllowUserToResizeColumns not working

    I never got an answer to this post, and subsequently forgot about the issue. Well, today I ran into it again and went on the web to search for an answer, and the first page that came up in my search was my original post.
    I always add to the reputation of those whose posts are helpful, and even occasionally to those whose posts aren't helpful but who obviously put forth a valiant effort. That is, when the system will allow it.
    My war with a browser-redirect trojan

  3. #3

    Thread Starter
    Frenzied Member dolot's Avatar
    Join Date
    Nov 2007
    Location
    Ancient City, U.S.
    Posts
    1,254

    Re: Datagridview AllowUserToResizeColumns not working

    So I read the following on a microsoft website:

    Columns in fill mode divide the available control width in proportions indicated by their FillWeight property values. The width available for fill mode is determined by subtracting the widths of all other columns from the width of the client area of the control. If this width is smaller than the combined MinimumWidth values of all fill-mode columns, the horizontal scroll bar is displayed, all fill-mode columns are shown with their minimum widths, and user column-resizing is disabled.

    Since I'm setting the AutoSizeColumnsMode property to 'AllCells', that seems to be disabling the column-resizing.

    So now the question is: How do if fix it? I can, of course, change the AutoSizeColumnsMode property, but that will lead to a less ideal user experience.

    Any ideas welcome.
    I always add to the reputation of those whose posts are helpful, and even occasionally to those whose posts aren't helpful but who obviously put forth a valiant effort. That is, when the system will allow it.
    My war with a browser-redirect trojan

  4. #4
    Junior Member
    Join Date
    Oct 2013
    Location
    California
    Posts
    16

    Re: Datagridview AllowUserToResizeColumns not working

    I know this is an old post, but thought I'd add this in case anyone else is still looking for the solution like I was.

    Dolot, you were right that setting the AutoSizeColumnsMode property to 'AllCells' was disabling column-resizing. This documentation says that any automatic sizing of columns disables the user's ability to alter column width. I found that setting both the column's autosizemode to 'NotSet' (the default), and also the datagridview's Autosizecolumnsmode to 'None' and then using the datagridview.autoresizecolumns method should accomplish the trick. It allows the user to reset the size, but formats the size to fit the data.

  5. #5
    Junior Member
    Join Date
    Oct 2013
    Location
    California
    Posts
    16

    Re: Datagridview AllowUserToResizeColumns not working

    xxxx
    Last edited by Greydog1; Nov 19th, 2018 at 10:27 PM. Reason: duplicate post

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width