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 / Languages / C# / November 2007

Tip: Looking for answers? Try searching our database.

Dynamic SplitterDistance

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Tom - 24 Nov 2007 08:30 GMT
My goal is to dynamically adjust a SplitContainer's vertical split
between a directory TreeView on the left and a detailed file ListView
on the right.

The code is working but does not initialize correctly.

Rough Method >>

1) Autosize columns by setting widths = -1.
2) Clear items from list.
3) Fill list.
4) SplitterDistance = Form.ActiveForm.Width - 32 -
list.SumColumnWidths;

The "32" above is a trial and error factor that compensates for the
widths of the sizing borders, right scroll bar, and splitter width.
This technique works great AFTER the first screen is loaded. The
ListView has no extra space off to the right and 100% of the right
most column is visible. Thus the TreeView has maximum space and
produces a scroll bar if needed. The alignments stays sharp even upon
changing font sizes that force row height changes. It is slick!

Here is the root of the problem >>

At the end of the Form's constructor I placed print statements to echo
the column widths. They are all -1. Not until exiting the constructor
are the autosized columns' width property available for the
calculation. Thus the first screen splitter is not placed accurately.

This challenge is more about learning about objects than it is to just
make that first screen "pretty".

I've tried SuspendLayout() and various other guesses ... but obviously
no success.

Thanks for any help.

-- Tom
Michael Rubinstein - 24 Nov 2007 16:13 GMT
Tom, how about setting SplitterDistance in the form's Shown() event
handler? That should work.

Michael

> My goal is to dynamically adjust a SplitContainer's vertical split
> between a directory TreeView on the left and a detailed file ListView
[quoted text clipped - 34 lines]
>
> -- Tom
Tom - 24 Nov 2007 20:13 GMT
Michael -- THANK YOU !!

Your suggestion was **PERFECT** !!

I was unfamiliar with the Shown() method. In less than 10 minutes I
was able to get it working.

I wish my thank you could brighten your day as much as my day has been
brightened by your help. :)

This newsgroup rocks! Every_Single_Time I have posted here someone has
understood my predicament and set me on the right path. Awesome!

-- Tom

p.s. I replied previously and got some kind of authorization failure
to delivery bomb. I refreshed and did not see my previous attempt ...
so here I try again. If both show up ... my apologies for double
posting.

>    Tom, how about setting SplitterDistance in the form's Shown() event
>handler? That should work.
>
>Michael

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.