D
David Smith
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(string editPanelName)
{
switch (editPanelName)
{
case "General":
{
Vortex.UC_AccountGeneral editPanel;
editPanel = new UC_AccountGeneral();
break;
}
case "Numbers":
{
Vortex.UC_AccountNumbers editPanel;
editPanel = new UC_AccountNumbers();
break;
}
case "Address":
{
Vortex.UC_AccountAddress editPanel;
editPanel = new UC_AccountAddress();
break;
}
}
// Set location of panel
editPanel.Account = this.Account;
editPanel.Location = new System.Drawing.Point(128, 64);
editPanel.Width = this.Width - panel2.Width - 35;
editPanel.Height = this.Height - 110;
editPanel.Anchor =
(((
System.Windows.Forms.AnchorStyles.Top |
System.Windows.Forms.AnchorStyles.Bottom)|
System.Windows.Forms.AnchorStyles.Left) |
System.Windows.Forms.AnchorStyles.Right);
Controls.Add(editPanel);
editPanel.Show();
editPanel.BringToFront();
}
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(string editPanelName)
{
switch (editPanelName)
{
case "General":
{
Vortex.UC_AccountGeneral editPanel;
editPanel = new UC_AccountGeneral();
break;
}
case "Numbers":
{
Vortex.UC_AccountNumbers editPanel;
editPanel = new UC_AccountNumbers();
break;
}
case "Address":
{
Vortex.UC_AccountAddress editPanel;
editPanel = new UC_AccountAddress();
break;
}
}
// Set location of panel
editPanel.Account = this.Account;
editPanel.Location = new System.Drawing.Point(128, 64);
editPanel.Width = this.Width - panel2.Width - 35;
editPanel.Height = this.Height - 110;
editPanel.Anchor =
(((
System.Windows.Forms.AnchorStyles.Top |
System.Windows.Forms.AnchorStyles.Bottom)|
System.Windows.Forms.AnchorStyles.Left) |
System.Windows.Forms.AnchorStyles.Right);
Controls.Add(editPanel);
editPanel.Show();
editPanel.BringToFront();
}