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# / March 2008

Tip: Looking for answers? Try searching our database.

Retaining dynamically added labels even when application is     restarted.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ketaki - 07 Mar 2008 12:17 GMT
Hello,
  I am facing a problem. I have a application in C# (winforms) where
I am giving an option to the user to add labels during runtime. But
when the application is restarted the labels that are added
during runtime get deleted. As the user is adding a label I do not
know the location of label. I want the labels added to appear in the
same location even when the application is restarted.
Please help.
Thanks
cfps.Christian - 07 Mar 2008 14:07 GMT
I did something similar only with buttons.  What I did was created an
object that told me the information I needed to know and serialized it
onto the user's hard drive.  If you're working on a more enterprise
application you could do the same into a database.  Once you've saved
it then just on the form load (in my case Log In) just grab the file
with the correct name (I based mine on user ID) and deserialize it
using the information to replace all the information.
Peter Duniho - 07 Mar 2008 17:47 GMT
> Hello,
>    I am facing a problem. I have a application in C# (winforms) where
[quoted text clipped - 3 lines]
> know the location of label. I want the labels added to appear in the
> same location even when the application is restarted.

If you have no way to enumerate the labels that were added (and thus find  
out their location), then you won't be able to do this.  So the first step  
is to fix your design if necessary so that you can enumerate the added  
labels.

Once you've done that, it's a simple matter to save the important  
information (pretty much whatever the user has control over, which might  
include text, position, font, color, whatever...you're pretty vague about  
what's going on so I can't offer specifics).  The question is "where to  
save it?"  You can write to a file or database as "cfps.Christian"  
suggests, but I'd say that in the most basic scenarios, you should just  
using the built-in Settings class and let .NET handle how to actually  
manage the data persistence.

Pete

Rate this thread:







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.