Click here to Skip to main content
15,890,506 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
AnswerRe: save my codes source Pin
Richard MacCutchan20-May-13 3:08
mveRichard MacCutchan20-May-13 3:08 
AnswerRe: save my codes source Pin
Abhinav S24-May-13 1:24
Abhinav S24-May-13 1:24 
AnswerRe: save my codes source Pin
MaulikDusara26-May-13 18:15
MaulikDusara26-May-13 18:15 
Questionvalidating on custom datagridview column Pin
sh-a19-May-13 23:56
sh-a19-May-13 23:56 
AnswerRe: validating on custom datagridview column Pin
sh-a22-May-13 4:27
sh-a22-May-13 4:27 
QuestionDialogBasics asin MFC. Pin
Bram van Kampen15-May-13 13:58
Bram van Kampen15-May-13 13:58 
AnswerRe: DialogBasics asin MFC. Pin
Richard MacCutchan15-May-13 22:10
mveRichard MacCutchan15-May-13 22:10 
GeneralRe: DialogBasics as in MFC. Pin
Bram van Kampen16-May-13 14:05
Bram van Kampen16-May-13 14:05 
Thanks Richard,

that clarified some aspects of the problem. Maybe I should slightly rephrase.
As soon as I call:
C#
result=lf.ShowDialog();

the dialog (or form) goes into some modal loop. I need to break out of that by clicking OK or Cancel. In other words, the handler code for the clicked button needs a method of breaking out of the modal loop.

N.B.Falling out of scope is a COMPILE time issue, never a RUN time issue. When execution reaches the closing scope brace, it will hit a compiler generated code block that carries out an effective cleanup and garbage collection. This would include (unlike MFC) that the Form Classes still displayed are automatically removed from the screen.

The form cannot fall out of scope while it is in the modal loop, and would remain on display forever. I used 'Dispose();' to break the circle, which on this occasion does the trick of breaking out of the loop. I am aware that this is not the proper way. For one, in doing so, lf is no longer available for interogation, and the line:
C#
variable=lf.textbox1

would throw an exception.
In MFC I would use OnOK(), OnCancel(), or sometimes even EndDialog(nResult). How do I break out of the modal loop from within say a Button Event handler in C#.NET.

Kind regards,
Smile | :)
Bram van Kampen


modified 16-May-13 20:34pm.

GeneralRe: DialogBasics as in MFC. Pin
Richard MacCutchan16-May-13 21:07
mveRichard MacCutchan16-May-13 21:07 
GeneralRe: DialogBasics as in MFC. Pin
Bram van Kampen17-May-13 9:35
Bram van Kampen17-May-13 9:35 
GeneralRe: DialogBasics as in MFC. Pin
Richard MacCutchan17-May-13 22:45
mveRichard MacCutchan17-May-13 22:45 
QuestionI suspect there's a Pattern for This: Optional Parameters vs. Overloading Pin
M-Badger15-May-13 11:43
M-Badger15-May-13 11:43 
AnswerRe: I suspect there's a Pattern for This: Optional Parameters vs. Overloading Pin
Eddy Vluggen16-May-13 5:01
professionalEddy Vluggen16-May-13 5:01 
GeneralRe: I suspect there's a Pattern for This: Optional Parameters vs. Overloading Pin
M-Badger16-May-13 8:34
M-Badger16-May-13 8:34 
GeneralRe: I suspect there's a Pattern for This: Optional Parameters vs. Overloading Pin
Eddy Vluggen16-May-13 9:13
professionalEddy Vluggen16-May-13 9:13 
GeneralRe: I suspect there's a Pattern for This: Optional Parameters vs. Overloading Pin
M-Badger16-May-13 9:57
M-Badger16-May-13 9:57 
GeneralRe: I suspect there's a Pattern for This: Optional Parameters vs. Overloading Pin
Eddy Vluggen16-May-13 11:25
professionalEddy Vluggen16-May-13 11:25 
GeneralRe: I suspect there's a Pattern for This: Optional Parameters vs. Overloading Pin
M-Badger16-May-13 9:58
M-Badger16-May-13 9:58 
GeneralRe: I suspect there's a Pattern for This: Optional Parameters vs. Overloading Pin
Eddy Vluggen16-May-13 11:26
professionalEddy Vluggen16-May-13 11:26 
AnswerRe: I suspect there's a Pattern for This: Optional Parameters vs. Overloading Pin
jschell16-May-13 7:57
jschell16-May-13 7:57 
GeneralRe: I suspect there's a Pattern for This: Optional Parameters vs. Overloading Pin
M-Badger16-May-13 8:37
M-Badger16-May-13 8:37 
GeneralRe: I suspect there's a Pattern for This: Optional Parameters vs. Overloading Pin
jschell17-May-13 10:13
jschell17-May-13 10:13 
AnswerRe: I suspect there's a Pattern for This: Optional Parameters vs. Overloading Pin
TnTinMn16-May-13 13:37
TnTinMn16-May-13 13:37 
GeneralRe: I suspect there's a Pattern for This: Optional Parameters vs. Overloading Pin
M-Badger17-May-13 6:49
M-Badger17-May-13 6:49 
GeneralRe: I suspect there's a Pattern for This: Optional Parameters vs. Overloading Pin
TnTinMn17-May-13 8:33
TnTinMn17-May-13 8:33 

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.