Solved

Visual Studio 2005 not letting me resize a Listbox control

Posted on 2007-03-27
4
417 Views
Last Modified: 2013-11-26
I am having trouble in Visual Studio 2005 with resizing of a listbox control.  I have the listbox control's Locked property = false, Enabled = true and a Size of 688, 407 with a Location of 22, 40.  

What I am trying to do is change the size of the listbox to 688, 412.  Seems simple right?  Well Visual Studio won't let me!  As soon as I change it, it snaps back to 407 almost as if it has somehow linked the two values together.  I tried even changing it in the Designer.cs code for that form, but it seems to ignore that code on display.  His all started happening after I set Locked = true and Enabled = false.  However, I switched both of those back, tried putting down an entirely new Listbox to see if i'd corrupted the other one somehow, tried rebooting Visual Studio etc all to no avail.  VS has decided it is smarter than me and won't let me make the changes.  I even checked the properties and turned off SnapGrid but i'm not in Snap layout mode so it shouldn't matter.

Help please!

Oh and before anyone suggests it, Listbox controls do NOT have an Autosize property.

Nathan
0
Comment
Question by:ironwill96
  • 2
  • 2
4 Comments
 
LVL 85

Expert Comment

by:Mike Tomlinson
Comment Utility
Lol...it does actually have an "AutoSize" property of sorts.

What it's doing is snapping the size of the ListBox so that rows of data are not chopped off.

This is based on the size of the Font selected.

Try this...

Populate the ListBox at Design-Time with a bunch of test data like:
a
b
c
d
...
enough to fill the listbox and then some.

Now adjust the height of the ListBox using its handles and watch where it snaps and how the rows appear inside.

Now make the size of the font large, something ridiculous like 36 point.

Resize again and watch what happens...
0
 
LVL 2

Author Comment

by:ironwill96
Comment Utility
Grr..anyway to turn off that feature since i'm using scroll bars anyway?

Thanks,
Nathan
0
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
Comment Utility
I'm not sure...never tried.  On a side note, this "snapping" occurs even when you have the ListBox anchored and/or docked and you are dynamically resizing the ListBoxes container...

Aha!...found it...not so cleverly hidden under the title of "ListBox.IntegralHeight":
http://msdn2.microsoft.com/en-us/library/system.windows.forms.listbox.integralheight.aspx
0
 
LVL 2

Author Comment

by:ironwill96
Comment Utility
Hehe, I guess that makes sense right?  I'd almost call it modulus more than integral, but whatever.   Thanks for the help!  It was driving me nuts!

Nathan
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now