Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / March 2008

Tip: Looking for answers? Try searching our database.

re-position of a text label

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
tat - 07 Mar 2008 16:42 GMT
Hi,

I have a simple question and I can't seem to find what I want after
google-ing.

I create a form with size, say 800x500.  I add a text label such that
it is at the center (400, 50). In the form properties I set
WindowState to Maximized. However, when I run the code, the text label
did not automatically adjust so that it can move to the center.  My
question is what properties of the text label do I need to change?

Thanks,
TAT
Bill Woodruff - 07 Mar 2008 23:49 GMT
> I create a form with size, say 800x500.  I add a text label such that
> it is at the center (400, 50). In the form properties I set
> WindowState to Maximized. However, when I run the code, the text label
> did not automatically adjust so that it can move to the center.  My
> question is what properties of the text label do I need to change?

One strategy would be :

1. create an event handler for the parent Form's resize event.

2. in that event handler take care of adjusting the label's position so it
is centered.

3. if you want to get fancier, you could check the WindowState property of
the parent Form in the re-size event and NOT change the position of the
label if the Form was minimized.

4. if you want to get obsessive-compulsive :), and the label size does not
change, you could pre-calculate half its width and height in the Form load
event, store the results in variables, and then re-use those values in the
Form resize event.This might save you some nanoseconds.

best, Bill
Jack Jackson - 08 Mar 2008 17:03 GMT
>Hi,
>
[quoted text clipped - 9 lines]
>Thanks,
>TAT

You could clear the Left from the label's Anchor property.  If neither
Left nor Right is set, the control will move horizontally by 1/2 of
the size change of the parent.  That may not quite keep it centered,
but it will be close.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.