By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,190 Members | 783 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,190 IT Pros & Developers. It's quick & easy.

Save the state of a SplitContainer

P: n/a

I want to save the state of a splitcontainer when an application ends. I
also save the form state. The SplitContainer does not seem to have a well
defined place to put intiialization and termination code.

I have tried to use my first splitter moved event to set the splitter
position but I am getting several splitter moved events before my form is
displayed. One is from the form initialization code and the second is from
my code that restore the form to it's original position and size.

Does anybody have a good method to know when to do the initialization.

Thanks
Tom Groszko
Mar 14 '07 #1
Share this Question
Share on Google+
7 Replies


P: n/a
The simplest way would be to bind the splitcontainer properties to
application settings and the bindingmanager will save the settings
automatically.

--
Bryan Phillips
MCSD, MCDBA, MCSE
Blog: http://bphillips76.spaces.live.com

"ne***************@charter.net" <ne***************@charter.netwrote in
message news:3d***************@newsfe04.lga:
I want to save the state of a splitcontainer when an application ends. I
also save the form state. The SplitContainer does not seem to have a well
defined place to put intiialization and termination code.

I have tried to use my first splitter moved event to set the splitter
position but I am getting several splitter moved events before my form is
displayed. One is from the form initialization code and the second is from
my code that restore the form to it's original position and size.

Does anybody have a good method to know when to do the initialization.

Thanks
Tom Groszko
Mar 14 '07 #2

P: n/a
Save and retrieving the data is not a problem. I have a well tested way to
keep them in a database. Applications settings don't work because Microsoft
is constantly changing the behaviour. It sometimes even can change when you
use one click install versus an old fasioned install so I don't use
Micorsoft mechanisms for this kind of data.

The real problem is that I cannot find an appropriate time to set the
SplitterDistance property. I cannot find an event that is called after all
else is done and before the splitter is first drawn.

Thanks for your response.
Tom Groszko
Mar 14 '07 #3

P: n/a
VJ
so once drawn you don't give the user a ability to move splitter, or maybe I
got that wrong...
If they are moving, the best place would be at your Application windows
close event...persist the state then...

VJ
<ne***************@charter.netwrote in message
news:cz***************@newsfe05.lga...
Save and retrieving the data is not a problem. I have a well tested way to
keep them in a database. Applications settings don't work because
Microsoft
is constantly changing the behaviour. It sometimes even can change when
you
use one click install versus an old fasioned install so I don't use
Micorsoft mechanisms for this kind of data.

The real problem is that I cannot find an appropriate time to set the
SplitterDistance property. I cannot find an event that is called after all
else is done and before the splitter is first drawn.

Thanks for your response.
Tom Groszko

Mar 14 '07 #4

P: n/a
Since there is no suitable event on the control itself, it may be best
to put the initialization code in the Form's Load event instead. If
this control is a subclass of the SplitContainer control, you could use
the ParentChanged event to set the SplitterDistance value.

--
Bryan Phillips
MCSD, MCDBA, MCSE
Blog: http://bphillips76.spaces.live.com

"ne***************@charter.net" <ne***************@charter.netwrote in
message news:cz***************@newsfe05.lga:
Save and retrieving the data is not a problem. I have a well tested way to
keep them in a database. Applications settings don't work because Microsoft
is constantly changing the behaviour. It sometimes even can change when you
use one click install versus an old fasioned install so I don't use
Micorsoft mechanisms for this kind of data.

The real problem is that I cannot find an appropriate time to set the
SplitterDistance property. I cannot find an event that is called after all
else is done and before the splitter is first drawn.

Thanks for your response.
Tom Groszko
Mar 15 '07 #5

P: n/a
The client can move it anytime they want. Moving is trivial to capture and
save. I am builing a subclass of splitcontainer. ParentChanged has not
worked because a control way down the chain does not know when it is finally
hooked up to a form and that form has run it's code to set the window to
it's previous state. I have attempted various things with ParentChanged and
FindForm but nothing seems to work well for control not directly on the
form. I also have a form subclass that when it does it's set to the previous
state looks at all it's child controls and the child's children etc for a
control that is my splitcontainer and asks the container to to the initial
set but is seem that controls on tab pages way down the chain have not been
built yet.

Thanks again for your thoughts.

Tom Groszko
Mar 16 '07 #6

P: n/a
If I save the SplitterDistance as a percent of the whole control I no longer
have to be concern with the window not being the same size as when I save
the value. If I look during the resize, splittermoved and resumelayout
routines and insure that the control name is filled in I am close to what I
want.

A remaining problem is I need to uniquely name each of these for an
application. I am not sure how to make the name unique for these when they
are embedded in other user controls that can be used in several places
within the application.

Thanks again
Tom Groszko
Mar 16 '07 #7

P: n/a
You could use Reflector (www.aisto.com/roeder) to look at how ASP.Net
generates unique names and emulate that approach.

--
Bryan Phillips
MCSD, MCDBA, MCSE
Blog: http://bphillips76.spaces.live.com

"ne***************@charter.net" <ne***************@charter.netwrote in
message news:EN*************@newsfe03.lga:
If I save the SplitterDistance as a percent of the whole control I no longer
have to be concern with the window not being the same size as when I save
the value. If I look during the resize, splittermoved and resumelayout
routines and insure that the control name is filled in I am close to what I
want.

A remaining problem is I need to uniquely name each of these for an
application. I am not sure how to make the name unique for these when they
are embedded in other user controls that can be used in several places
within the application.

Thanks again
Tom Groszko
Mar 17 '07 #8

This discussion thread is closed

Replies have been disabled for this discussion.