When I'm changing windows(forms), my application's icon disappears from taskbar. So for opening the application, users need to click ALT+TAB to select the form which is hidden from taskbar. After users choose application, icon comes to taskbar again. I don't want my applcation icon disappears from taskbar.
My codes are below:
//Program.cs
[STAThread]
static void Main()
{
Application.Run(new LoginPage());
}
Login Page is application's first screen that gets username and password. After clicking submit button application is going to main page.
//LoginPage.cs
private void submitBtn_Click(object sender, EventArgs e)
{
MainPage mainPage= new MainPage();
mainPage.Show();
this.Hide();
}
Lets say I have a button on main page for going to another form. Here when I click the page1 button taskbar icon disappears.
//MainPage.cs
private void page1Btn_Click(object sender, EventArgs e)
{
Page1 page1 = new Page1();
page1.Show();
this.Hide();
}
After some research I found one solution for that but there is another problem which I cannot minimize the form correctly.
When I change the codes above with below
//MainPage.cs
private void page1Btn_Click(object sender, EventArgs e)
{
Page1 page1= new Page1();
page1.ShowInTaskbar = false;
page1.Owner = this;
page1.ShowDialog();
this.Hide();
}
Here, I also need to modify Page1 as below
//Page1.cs
private void Page1_FormClosed(object sender, FormClosedEventArgs e)
{
MainPage mainPage = new MainPage();
mainPage.Show();
}
Here I can successfully go to page1 step by step (without disappearing the taskbar icon). When I minimize the page1, it minimizes the application as expected but when I maximize the application from taskbar, I expect Page1 should maximizes but MainPage maximizes with an minimized Page one like below image.
I only want to correct these problems. I hope there is experts which experienced these things there.
Problem is solved.
The problem was, I was maximizing the form from properties of the page.
Instead of maximizing it from properties, I do it manually from Page Load and its solved.
this.Bounds = Screen.PrimaryScreen.WorkingArea;