How to have multiple icons for one form?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Basically, I would like the app pick up different icons based on the
informaiton in my constructor. I may use this form for different purposes and
would like it change icons based on the codes.
Thanks

Chris
 
Chris,

Why not use polymorphism to help you?

You would make a base class, and then have this in the constructor:

// Set the icon.
this.Icon = this.GetFormIcon();

Then, in your base class, you have this defined:

protected virtual Icon GetFormIcon()
{
// Return some standard icon.
}

Then, for different forms, you derive from the base class, and override
the GetFormIcon method to return the appropriate icon. It's a more elegant
solution than big switch statements.

Hope this helps.
 
Back
Top