Hi there. i am new to C# programming. I am developing an updater that would update our product. I want to program the close button so if clicked the application should not close but rather hide. I have a notification icon from where the user can call it back. I want it just like in msn messenger.

Recommended Answers

All 3 Replies

try Hide and Show for the form

//Hides 
Form.Hide();
//you can use this if you are in the form's code
this.Hide();

//Show the form
Form.Show();
//in the form's code
this.Show();

Hi there. I have done it my self. Thought it would be better to share. What I wanted to do was to use notification Icon and when user clicks close button the applicaton should hide and the user could call it back by clicking on the notification icon.
The following is the code written in form_close event

e.cancel;
this.hide();

Hi,
This is working but sometimes u need to close the form then ..
Make a boolean variable. then check it for close operation.

Try

bool bUserClose = true;
    private void Form1_Click(object sender, EventArgs e)
    {
        bUserClose = false;
        Close();
    }

    private void Form1_FormClosing(object sender, FormClosingEventArgs e)
    {
        if (bUserClose)
        {
            e.Cancel = true;
            Hide();
        }
    }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.