?
Solved

Visual Studio 2005 not letting me resize a Listbox control

Posted on 2007-03-27
4
Medium Priority
?
436 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 86

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 86

Accepted Solution

by:
Mike Tomlinson earned 2000 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

Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

Question has a verified solution.

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

This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses
Course of the Month16 days, 16 hours left to enroll

862 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