Click here to Skip to main content
15,887,404 members
Home / Discussions / C#
   

C#

 
GeneralRe: Restoring Initial UI State Pin
Dave Kreskowiak2-May-13 11:06
mveDave Kreskowiak2-May-13 11:06 
GeneralRe: Restoring Initial UI State Pin
Jasmine25012-May-13 12:36
Jasmine25012-May-13 12:36 
GeneralRe: Restoring Initial UI State Pin
Dave Kreskowiak2-May-13 15:35
mveDave Kreskowiak2-May-13 15:35 
GeneralRe: Restoring Initial UI State Pin
Jasmine25013-May-13 5:08
Jasmine25013-May-13 5:08 
GeneralRe: Restoring Initial UI State Pin
Eddy Vluggen2-May-13 12:21
professionalEddy Vluggen2-May-13 12:21 
GeneralRe: Restoring Initial UI State Pin
Matt U.3-May-13 1:54
Matt U.3-May-13 1:54 
AnswerRe: Restoring Initial UI State Pin
Jasmine25012-May-13 7:04
Jasmine25012-May-13 7:04 
AnswerRe: Restoring Initial UI State Pin
Eddy Vluggen2-May-13 11:18
professionalEddy Vluggen2-May-13 11:18 
Matt U. wrote:
But I've always found it a bit tedious and time consuming to restore the UI to its initial state when the user saves an entry, for example.
C#
// Dirty hack
Form.Controls.Clear();
InitializeComponent();

Alternatively, loop all controls using reflection (no, it ain't that slow, just a bit of an exercise to get recursion working) and clear them.

How do your edit-forms look like? Mine could be explained as a PropertyGrid on a dialog-form. It has an extra button called "reset", which just reloads a cloned object into the propertygrid.

It's not a real property-grid anymore; it's a custom control that behaves in a similar way (in code), but that renders a more 'traditional' winform.

I choose this architecture out of convenience; a single modification in the object, and it's pushed to a Memento-pattern (undo/redo stack). When closing, the content of both get serialized and saved. When loaded, both are restored - it makes users happy when they find out that they can "undo" yesterday's changes, even if the PC was turned of in the mean time.
Bastard Programmer from Hell Suspicious | :suss:
If you can't read my code, try converting it here[^]

GeneralRe: Restoring Initial UI State Pin
Jasmine25012-May-13 12:35
Jasmine25012-May-13 12:35 
GeneralRe: Restoring Initial UI State Pin
Eddy Vluggen3-May-13 1:35
professionalEddy Vluggen3-May-13 1:35 
AnswerRe: Restoring Initial UI State Pin
Clifford Nelson2-May-13 17:12
Clifford Nelson2-May-13 17:12 
QuestionAttendance System Pin
behrouz shamlo2-May-13 2:43
behrouz shamlo2-May-13 2:43 
AnswerRe: Attendance System Pin
OriginalGriff2-May-13 4:44
mveOriginalGriff2-May-13 4:44 
AnswerRe: Attendance System Pin
Eddy Vluggen2-May-13 5:06
professionalEddy Vluggen2-May-13 5:06 
AnswerRe: Attendance System Pin
Abhinav S2-May-13 6:09
Abhinav S2-May-13 6:09 
GeneralRe: Attendance System Pin
Eddy Vluggen2-May-13 11:09
professionalEddy Vluggen2-May-13 11:09 
GeneralRe: Attendance System Pin
behrouz shamlo8-May-13 2:22
behrouz shamlo8-May-13 2:22 
GeneralRe: Attendance System Pin
Eddy Vluggen8-May-13 7:04
professionalEddy Vluggen8-May-13 7:04 
Questiondraw row column cube c# Pin
nimolZero1-May-13 23:56
nimolZero1-May-13 23:56 
AnswerRe: draw row column cube c# Pin
Abhinav S2-May-13 0:20
Abhinav S2-May-13 0:20 
GeneralRe: draw row column cube c# Pin
nimolZero2-May-13 14:03
nimolZero2-May-13 14:03 
AnswerRe: draw row column cube c# Pin
Jasmine25012-May-13 5:58
Jasmine25012-May-13 5:58 
QuestionCompile warnings as errors. Pin
Septimus Hedgehog1-May-13 23:10
Septimus Hedgehog1-May-13 23:10 
SuggestionRe: Compile warnings as errors. Pin
Maarten Kools1-May-13 23:34
professionalMaarten Kools1-May-13 23:34 
AnswerRe: Compile warnings as errors. Pin
Abhinav S1-May-13 23:38
Abhinav S1-May-13 23:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.