|
C# • Implement Properties Listing 1. This code enables you to implement properties for a custom user control. All told, this code sets three properties: SetQ, PanelColor, and Choice. Custom user controls are one of the most powerful features of Visual Studio, enabling you to achieve significant code reuse, often while relying heavily on the work of others to begin with. public enum Choices
{
Agree = 1,
DisAgree = 2,
Undecided = 3,
}
public string SetQ
{
set {qLabel.Text = value;}
get {return(qLabel.Text);}
}
public Color PanelColor
{
set {panel1.BackColor= value;}
get {return(panel1.BackColor);}
}
public Choices Choice
{
get
{
Choices usel;
usel = Choices.Undecided;
if (radDisagree.Checked) usel= Choices.DisAgree;
if (radAgree.Checked) usel = Choices.Agree;
return(usel);}
}
}
|