Hello,
I have button on my main form..
I have panel on form..
I have several other forms.. say accounting1, accounting 2,accounting3
On button click I want to call a particular form(accounting1) in panel..
now on button click I want to call accounting 2 in panel..
Problem is I am using single button to call forms
How to maintain this sequence on single button.. Can anyone give me code..
Its urgent
Loading
Danatas GerviPosted Oct 5, 2009, 8:48 AM
Simplest copy paste way (say only 3 different forms exists and will be forever ;-) )
private void button1_Click(object sender, EventArgs e)
{
if (MdiChildren.ToList().Exists(anyAcc =>
{
return anyAcc.Name == "Acc1";
}) == false)
{
Form acc = new Form();
acc.Name = "Acc1"; // this is the key!
acc.Text = acc.Name;
acc.MdiParent = this;
acc.Show();
return;
}
if (MdiChildren.ToList().Exists(anyAcc =>
{
return anyAcc.Name == "Acc2";
}) == false)
{
Form acc = new Form();
acc.Name = "Acc2"; // this is the key!
acc.Text = acc.Name;
acc.MdiParent = this;
acc.Show();
return;
}
if (MdiChildren.ToList().Exists(anyAcc =>
{
return anyAcc.Name == "Acc3";
}) == false)
{
Form acc = new Form();
acc.Name = "Acc3"; // this is the key!
acc.Text = acc.Name;
acc.MdiParent = this;
acc.Show();
return;
}
I have used MDI interface.
By my opinion, for using on the pannel the UserControls is better.
;-)