Reputation:
I want to hide my form when I press a button inside the form. When I do this, something must be shown in the taskbar, and if I click that thing form will again come into visible state.
Edit: I am not supposed to minimize or resize the form.
Upvotes: 0
Views: 1465
Reputation: 3075
Use the Form's property "Opacity".
// Hide your windows frame
form1.Opacity = 0;
/*
* Your actions Here
*/
// Show your windows frame
form1.Opacity = 1.0;
Upvotes: 0
Reputation: 1179
As nils said.
Hide();
// or
Visible = false;
NotifyIcon trayIcon;
//....
trayIcon.Visible = true;
Show/hide the trayicon depending on forms visibility.
Upvotes: 1
Reputation: 76001
You have two options:
Form.WindowState
property to FormWindowState.Minimized
or just let the user use the standard minimize button. This will "hide" the form, but will leave its button on the taskbar, and the user can click it to bring the form back.EDIT: Based on your question edit, you should use NotifyIcon
.
NotifyIcon
component to your form. Then, on your button click handler, you will call Form.Close
to close the form. When the user wants to bring the form back, they will click on the syastem tray icon representing your app and you will open the form.Here's an VB.NET example of how to do this. It shouldn't be hard to translate in C#. You can also search for NotifyIcon
to see more examples.
Upvotes: 6
Reputation: 5569
//this is Form object
//Option 1
this.Hide();
//Option 2
this.Visible = false;
Upvotes: 2
Reputation: 1267
in the button code:
FormBorderStyle = FormBorderStyle.None;
Width = 0;
Height = 0;
in say... the Activated form event:
FormBorderStyle = FormBorderStyle.Fixed3D;
Width = 800;
Height = 500;
Would this effect be right for you?
Upvotes: 1
Reputation: 34515
Does standard minimize button comply with the requirements?
Upvotes: 1