Im trying the following code: (pardon the indentations... weird newsreader)
The obvious problem here is that the editPanel object is defined within the
blocks, and out of scope outside of the switch statement where I want to set
some basic parameters before diplaying it (Its a usercontrol).
Anyway, Im trying to avoid creating a "base" object to inherit from in order
to use this code, and I cant cast the object since the later code has no
idea what type it is. Any suggestions?
Thanks
David
private void ShowEditPanel(s tring editPanelName)
{
switch (editPanelName)
{
case "General":
{
Vortex.UC_Accou ntGeneral editPanel;
editPanel = new UC_AccountGener al();
break;
}
case "Numbers":
{
Vortex.UC_Accou ntNumbers editPanel;
editPanel = new UC_AccountNumbe rs();
break;
}
case "Address":
{
Vortex.UC_Accou ntAddress editPanel;
editPanel = new UC_AccountAddre ss();
break;
}
}
// Set location of panel
editPanel.Accou nt = this.Account;
editPanel.Locat ion = new System.Drawing. Point(128, 64);
editPanel.Width = this.Width - panel2.Width - 35;
editPanel.Heigh t = this.Height - 110;
editPanel.Ancho r =
(((
System.Windows. Forms.AnchorSty les.Top |
System.Windows. Forms.AnchorSty les.Bottom)|
System.Windows. Forms.AnchorSty les.Left) |
System.Windows. Forms.AnchorSty les.Right);
Controls.Add(ed itPanel);
editPanel.Show( );
editPanel.Bring ToFront();
}
The obvious problem here is that the editPanel object is defined within the
blocks, and out of scope outside of the switch statement where I want to set
some basic parameters before diplaying it (Its a usercontrol).
Anyway, Im trying to avoid creating a "base" object to inherit from in order
to use this code, and I cant cast the object since the later code has no
idea what type it is. Any suggestions?
Thanks
David
private void ShowEditPanel(s tring editPanelName)
{
switch (editPanelName)
{
case "General":
{
Vortex.UC_Accou ntGeneral editPanel;
editPanel = new UC_AccountGener al();
break;
}
case "Numbers":
{
Vortex.UC_Accou ntNumbers editPanel;
editPanel = new UC_AccountNumbe rs();
break;
}
case "Address":
{
Vortex.UC_Accou ntAddress editPanel;
editPanel = new UC_AccountAddre ss();
break;
}
}
// Set location of panel
editPanel.Accou nt = this.Account;
editPanel.Locat ion = new System.Drawing. Point(128, 64);
editPanel.Width = this.Width - panel2.Width - 35;
editPanel.Heigh t = this.Height - 110;
editPanel.Ancho r =
(((
System.Windows. Forms.AnchorSty les.Top |
System.Windows. Forms.AnchorSty les.Bottom)|
System.Windows. Forms.AnchorSty les.Left) |
System.Windows. Forms.AnchorSty les.Right);
Controls.Add(ed itPanel);
editPanel.Show( );
editPanel.Bring ToFront();
}
Comment