Click here to Skip to main content
15,913,055 members
Home / Discussions / C#
   

C#

 
GeneralRe: Can't run SC remotely to config service Pin
SledgeHammer013-May-13 8:04
SledgeHammer013-May-13 8:04 
GeneralRe: Can't run SC remotely to config service Pin
Dave Kreskowiak3-May-13 8:26
mveDave Kreskowiak3-May-13 8:26 
GeneralRe: Can't run SC remotely to config service Pin
SledgeHammer013-May-13 9:40
SledgeHammer013-May-13 9:40 
GeneralRe: Can't run SC remotely to config service Pin
SledgeHammer013-May-13 11:10
SledgeHammer013-May-13 11:10 
AnswerRe: Can't run SC remotely to config service Pin
Richard MacCutchan2-May-13 21:37
mveRichard MacCutchan2-May-13 21:37 
GeneralRe: Can't run SC remotely to config service Pin
SledgeHammer013-May-13 4:02
SledgeHammer013-May-13 4:02 
GeneralRe: Can't run SC remotely to config service Pin
Richard MacCutchan3-May-13 4:22
mveRichard MacCutchan3-May-13 4:22 
AnswerRe: Can't run SC remotely to config service Pin
Alan N2-May-13 22:50
Alan N2-May-13 22:50 
GeneralRe: Can't run SC remotely to config service Pin
SledgeHammer013-May-13 4:08
SledgeHammer013-May-13 4:08 
GeneralRe: Can't run SC remotely to config service Pin
Alan N22-May-13 4:33
Alan N22-May-13 4:33 
QuestionRestoring Initial UI State Pin
Matt U.2-May-13 2:53
Matt U.2-May-13 2:53 
AnswerRe: Restoring Initial UI State Pin
Alan Balkany2-May-13 5:19
Alan Balkany2-May-13 5:19 
GeneralRe: Restoring Initial UI State Pin
Matt U.2-May-13 5:39
Matt U.2-May-13 5:39 
GeneralRe: Restoring Initial UI State Pin
Jasmine25012-May-13 7:10
Jasmine25012-May-13 7:10 
GeneralRe: Restoring Initial UI State Pin
Matt U.2-May-13 7:15
Matt U.2-May-13 7:15 
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 

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.