Click here to Skip to main content
15,890,741 members
Home / Discussions / C#
   

C#

 
GeneralRe: MDI Behaviour Pin
Ashok Dhamija5-Jun-05 22:24
Ashok Dhamija5-Jun-05 22:24 
GeneralRe: MDI Behaviour Pin
Maqsood Ahmed5-Jun-05 22:31
Maqsood Ahmed5-Jun-05 22:31 
GeneralRe: MDI Behaviour Pin
Ashok Dhamija5-Jun-05 23:18
Ashok Dhamija5-Jun-05 23:18 
GeneralRe: MDI Behaviour Pin
Rizwan Bashir6-Jun-05 3:40
Rizwan Bashir6-Jun-05 3:40 
GeneralStupid WinForms Pin
Christian Graus5-Jun-05 21:32
protectorChristian Graus5-Jun-05 21:32 
GeneralRe: Stupid WinForms Pin
Ashok Dhamija5-Jun-05 22:13
Ashok Dhamija5-Jun-05 22:13 
GeneralRe: Stupid WinForms Pin
Christian Graus6-Jun-05 12:20
protectorChristian Graus6-Jun-05 12:20 
GeneralRe: Stupid WinForms Pin
Ashok Dhamija6-Jun-05 18:54
Ashok Dhamija6-Jun-05 18:54 
May I suggest the following scheme, as I tested it in my test application:

In Form1, I put the following code for button1 to display Form2 as a modal dialog:

private void button1_Click(object sender, System.EventArgs e)
{
	Form2 form2 = new Form2();
	form2.ShowDialog();
}


Then, in Form2, I put 2 buttons, button1 (to display Form3 as a modal dialog) and button2 (to close Form2), with the following code:

private void button1_Click(object sender, System.EventArgs e)
{
	Form3 form3 = new Form3();
	form3.ShowDialog();		
}

private void button2_Click(object sender, System.EventArgs e)
{
	this.Close();
}


I have put button1 in Form3, with the code to close it as under:

private void button1_Click(object sender, System.EventArgs e)
{
	this.Close();
}


Now, when I show Form2 and then Form3 as modal dialog boxes from buttons in Form1 and Form2 respectively, they are properly shown. Similarly, when I close Form3 by clicking button1 on it (which uses this.Close() method and of course it can contain other code before that), it closes properly, and the important thing is that Form2 (which is the parent form for Form3) is NOT closed in this manner. Likewise, when I close Form2 by clicking button2 on it by using this.Close() method, Form2 closes properly and again it is pertinent to note that the parent form Form1 is not closed.

So, in this manner, the whole behaviour is as expected and correct. The only important aspect to note is that:

1. I am using the simple form2.ShowDialog() method, without using the DialogResult. Secondly, the actual functionality is added on the dialog form itself in its various buttons (instead of putting the same directly in parent form in the format of if(dialogResult == DialogResult.OK), etc.).

I wonder whether your application can be suitably modified to this pattern.

I really do not know whether all this is of any use to you.

Regards,
GeneralRe: Stupid WinForms Pin
Christian Graus6-Jun-05 18:58
protectorChristian Graus6-Jun-05 18:58 
GeneralRe: Stupid WinForms Pin
Maqsood Ahmed5-Jun-05 22:16
Maqsood Ahmed5-Jun-05 22:16 
GeneralRe: Stupid WinForms Pin
Christian Graus6-Jun-05 12:20
protectorChristian Graus6-Jun-05 12:20 
GeneralRe: Stupid WinForms Pin
S. Senthil Kumar6-Jun-05 0:42
S. Senthil Kumar6-Jun-05 0:42 
GeneralRe: Stupid WinForms Pin
Christian Graus6-Jun-05 12:21
protectorChristian Graus6-Jun-05 12:21 
Generalsql stored preocedure Pin
Mohammad Daba'an5-Jun-05 20:08
Mohammad Daba'an5-Jun-05 20:08 
GeneralRe: sql stored preocedure Pin
Colin Angus Mackay5-Jun-05 20:51
Colin Angus Mackay5-Jun-05 20:51 
GeneralRe: sql stored preocedure Pin
Mohammad Daba'an5-Jun-05 22:51
Mohammad Daba'an5-Jun-05 22:51 
GeneralRe: sql stored preocedure Pin
Colin Angus Mackay6-Jun-05 0:28
Colin Angus Mackay6-Jun-05 0:28 
GeneralRe: sql stored preocedure Pin
Mohammad Daba'an6-Jun-05 0:44
Mohammad Daba'an6-Jun-05 0:44 
GeneralFriend Assembly Help needed... Pin
chettu5-Jun-05 19:15
chettu5-Jun-05 19:15 
GeneralRe: Friend Assembly Help needed... Pin
oykica6-Jun-05 6:57
oykica6-Jun-05 6:57 
GeneralRe: Friend Assembly Help needed... Pin
pavel.drtil26-May-10 1:18
pavel.drtil26-May-10 1:18 
GeneralMy own little lexer/parser (trouble even getting started) Pin
Insolence5-Jun-05 18:50
Insolence5-Jun-05 18:50 
QuestionHow to save Images in Mysql DataBase Through C# Pin
monica2k5-Jun-05 18:37
monica2k5-Jun-05 18:37 
AnswerRe: How to save Images in Mysql DataBase Through C# Pin
Christian Graus5-Jun-05 18:39
protectorChristian Graus5-Jun-05 18:39 
GeneralRe: How to save Images in Mysql DataBase Through C# Pin
monica2k5-Jun-05 19:07
monica2k5-Jun-05 19:07 

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.