|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Save the state of a SplitContainerI 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 The simplest way would be to bind the splitcontainer properties to
application settings and the bindingmanager will save the settings automatically. Show quote "newscorrespond***@charter.net" <newscorrespond***@charter.net> wrote in message news:3dHJh.213$g26.132@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 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 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 <newscorrespond***@charter.net> wrote in message Show quote news:cz_Jh.358$WE4.246@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 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. Show quote "newscorrespond***@charter.net" <newscorrespond***@charter.net> wrote in message news:cz_Jh.358$WE4.246@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 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 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 You could use Reflector (www.aisto.com/roeder) to look at how ASP.Net
generates unique names and emulate that approach. Show quote "newscorrespond***@charter.net" <newscorrespond***@charter.net> wrote in message news:ENEKh.33$JS1.12@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 |
|||||||||||||||||||||||