Results 1 to 6 of 6

Thread: [RESOLVED] Another UI Oddity that is bothering me

  1. #1

    Thread Starter
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Resolved [RESOLVED] Another UI Oddity that is bothering me

    I have a ListView setup in Detailed view. I have 3 columns. No matter what width I set the columns, they look great in designer view but when I run the application they are squished and you can't even read the labels.

    I have tried this:
    VB Code:
    1. MyColumn1.AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize);

    But that does nothing, as does its other modes. Also, adding and removing items from the list does not change the column width.

    Setting the column width manually also does not change it.

    The only way to change it is manually but I'd rather not do to.
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Another UI Oddity that is bothering me

    The ListView.AutoResizeColumns and ColumnHeader.AutoResize methods will only work once the ListView has items in it. Also, if you add additional items then the columns will not autoresize themselves. You must call the method again.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Another UI Oddity that is bothering me

    Actually, forget the bit about items being required. That may have been a misinterpretation of the help on my part. I just added a ListView with three columns and a Button to a form. I called AutoResizeColumns on the ListView from the button Click without adding any items and it worked fine.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4

    Thread Starter
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: Another UI Oddity that is bothering me

    Thanks. I just tried it and it works after data has been added to the ListView.

    Is there anyway to make the columns a fixed width before data is entered or do I have to enter data?
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Another UI Oddity that is bothering me

    I'm not sure why it won't work for you without data. The help implies that that is so but I just called AutoResizeColumns on the ListView in the form's Load event handler without any items and it worked fine. I guess that as a hack you could add a blank item, resize the columns and then remove the item.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  6. #6

    Thread Starter
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: Another UI Oddity that is bothering me

    Thanks. I got it to work.

    I was, stupidly, putting the call to AutoResizeColumns in the Constructor of my control instead of the Load event.

    Thanks a lot. Too bad I can't give you any ratings (I've tried everytime you answered a question and it says I have to spread it around (I rated you once before, lol))
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

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