Solved

Visual Studio 2005 not letting me resize a Listbox control

Posted on 2007-03-27
4
419 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
ID: 18804512
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
ID: 18804589
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
ID: 18804614
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
ID: 18804785
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to save a picture box in a specific network folder using vb.net 2013 7 26
asp.net mvc input file 2 32
Get id from json Data with NewtonSoft 3 31
Run time Error 4 34
In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

948 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

22 Experts available now in Live!

Get 1:1 Help Now