New topic: Keeing ListBox centered in window?
<http://forums.realsoftware.com/viewtopic.php?t=38306> Page 1 of 1 [ 4 posts ] Previous topic | Next topic Author Message tudorH Post subject: Keeing ListBox centered in window?Posted: Thu Mar 24, 2011 5:55 pm Joined: Thu Feb 03, 2011 5:44 pm Posts: 31 How would I go about keeping a listbox centered in a window? If the window is resized (made bigger) the listbox should stay the same size but is centered on the bigger window, likewise when the window is resized (made smaller) the listbox should get cut off when the window becomes smaller than the listbox.. Thanks in advance Top bob_barr Post subject: Re: Keeing ListBox centered in window?Posted: Thu Mar 24, 2011 6:07 pm Joined: Sat Mar 25, 2006 1:39 pm Posts: 860 Location: Morgan Hill, CA This should work: Calculate a new value for the ListBox's "Left" property value whenever the window is resized. [caution - untested code] Code:If Window1.Width > lstBox1. Width Then NewLeft = (Window1.Width - lstBox1.Width) / 2 Else NewLeft = 0 End If lstBox1.Left = NewLeft Doing this should split the margin equally between the two sides of the window, keeping it centered. _________________ While fairly new to RB, I've been programming ever since that darned mastadon stepped on my abacus. Using RB 2009r5.1 on XP and Windows 7. Top tudorH Post subject: Re: Keeing ListBox centered in window?Posted: Thu Mar 24, 2011 6:22 pm Joined: Thu Feb 03, 2011 5:44 pm Posts: 31 Thanks! That works Top silvs Post subject: Re: Keeing ListBox centered in window?Posted: Thu Mar 24, 2011 10:24 pm Joined: Fri Aug 27, 2010 12:28 am Posts: 3 dont forget to also add to maximise and restore _________________ RS 2011r1 Enterprise MBP 17" i7: 10.7 AMD2 64bit: Ubuntu 11.04 MBP 15" i7: Windows7 Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 4 posts ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
