Click here to Skip to main content
15,922,894 members
Home / Discussions / C#
   

C#

 
GeneralRe: System.Windows.Form equivalent of PeekMessage() Pin
Ravi Bhavnani6-Jan-06 1:36
professionalRavi Bhavnani6-Jan-06 1:36 
QuestionFile Operations Pin
dvsr5-Jan-06 12:07
dvsr5-Jan-06 12:07 
AnswerRe: File Operations Pin
mav.northwind5-Jan-06 12:26
mav.northwind5-Jan-06 12:26 
Questionnewbee ques Pin
Manu_815-Jan-06 9:30
Manu_815-Jan-06 9:30 
AnswerRe: newbee ques Pin
Christian Graus5-Jan-06 10:26
protectorChristian Graus5-Jan-06 10:26 
AnswerRe: newbee ques Pin
Le centriste5-Jan-06 10:34
Le centriste5-Jan-06 10:34 
GeneralRe: newbee ques Pin
Manu_815-Jan-06 10:43
Manu_815-Jan-06 10:43 
AnswerRe: newbee ques Pin
Le centriste5-Jan-06 10:54
Le centriste5-Jan-06 10:54 
I see some problems here: in the button3 handler, you instantiate a new instance of the MainForm. I suggest that you implement a constructor for EnggHome that takes a handle to the HomeForm parent form, and keep it among its private data members. In the button3 handler button for EnggForm, just call the HomeForm.Close() method.

public class EnggHome : Form
{
     private Form _parentForm;

     public EnggHome(Form parentForm)
     {
          this._parentForm = parentForm;
     }

     private void button3_Click(object sender, System.EventArgs e)
     { 

          this.Dispose(true);
          this.Close();

          this._parentForm.Visible = true; <--- did you previously instantiate a new object to have you form reappear???
          this._parentForm.Dispose(); 
          this._parentForm.Close();

     }

}


and in the HomeForm class method, when instantiating the EnggHome object:

//in Home form
private void button3_Click(object sender, System.EventArgs e)
{
    EnggHome enggH = new EnggHome(this); <--- Notice the different constructor call.
    enggH.Show(); 
    this.Visible = false; 
}


A more drastic approach would be to call Application.Exit(0), but this would not give a chance to the parent form to clean up.

--------

"I say no to drugs, but they don't listen."
- Marilyn Manson

-- modified at 16:55 Thursday 5th January, 2006
GeneralRe: newbee ques Pin
Manu_815-Jan-06 11:18
Manu_815-Jan-06 11:18 
GeneralRe: newbee ques Pin
Le centriste5-Jan-06 11:26
Le centriste5-Jan-06 11:26 
GeneralRe: newbee ques Pin
Christian Graus5-Jan-06 12:00
protectorChristian Graus5-Jan-06 12:00 
GeneralOne more remark Pin
Le centriste5-Jan-06 10:59
Le centriste5-Jan-06 10:59 
GeneralRe: One more remark Pin
Manu_815-Jan-06 11:25
Manu_815-Jan-06 11:25 
AnswerRe: One more remark Pin
Le centriste5-Jan-06 11:27
Le centriste5-Jan-06 11:27 
QuestionRSA P/Q parameters help Pin
FotisSs5-Jan-06 9:10
FotisSs5-Jan-06 9:10 
QuestionBorder-Right to a asp:datagrid item by a CssClass Pin
thomasa5-Jan-06 9:10
thomasa5-Jan-06 9:10 
GeneralRe: Border-Right to a asp:datagrid item by a CssClass Pin
Guffa5-Jan-06 10:33
Guffa5-Jan-06 10:33 
GeneralRe: Border-Right to a asp:datagrid item by a CssClass Pin
thomasa5-Jan-06 21:41
thomasa5-Jan-06 21:41 
Questioncookies httpwebrequest Pin
TAREQ F ABUZUHRI5-Jan-06 8:45
TAREQ F ABUZUHRI5-Jan-06 8:45 
QuestionTheme selection for Windows Form Pin
VPMahank5-Jan-06 8:30
VPMahank5-Jan-06 8:30 
QuestionImageList.ImageSize supports only 255x255 pixel images. Pin
Alomgir Miah5-Jan-06 8:22
Alomgir Miah5-Jan-06 8:22 
QuestionC# DirectX 9 DSP Reference Pin
mark buckley5-Jan-06 7:56
mark buckley5-Jan-06 7:56 
AnswerRe: C# DirectX 9 DSP Reference Pin
Christian Graus5-Jan-06 10:28
protectorChristian Graus5-Jan-06 10:28 
GeneralRe: C# DirectX 9 DSP Reference Pin
User 66585-Jan-06 10:44
User 66585-Jan-06 10:44 
QuestionProtocol Handler for Http Pin
odleile5-Jan-06 7:16
odleile5-Jan-06 7:16 

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.