Reputation: 87
I have this link on my windows form in C# on visual studio:
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
// Show another form.
Form2 f2 = new Form2();
f2.Show(this);
linkLabel1.LinkVisited = true;
}
I want when i press the link,the new form which will be created to be on the same window and not appeared on another window.How can i do this?
Upvotes: 1
Views: 16481
Reputation: 521
Form.ShowDialog() didn't work for me. So I tried "MDI Container". Please check the link below.
How to open a new form window within same window in C#?
Upvotes: 0
Reputation: 431
you can create UserControls and swap the visible UserControl on a Form. To create user control check this link : create usercontrol
Upvotes: 0
Reputation: 27095
A form is inherently a Window
. If you want to do it without creating multiple Windows, create UserControl
s and swap the visible UserControl
on a Form.
Upvotes: 3
Reputation: 54001
The way I've usually seen this done is the show the new form and hide the previous one.
This gives the appearance of the same window being used.
Something like:
this.Hide();
f2.Show();
Upvotes: 3
Reputation:
change your .Show
to .ShowDialog
. This will make it a modal dialog "window".
Upvotes: 0