We help IT Professionals succeed at work.
Get Started

DefaultValueAttribute and System.Drawing.. objects

925 Views
Last Modified: 2013-11-26
I would like to use the DefaultValueAttribute to set a default for a property that returns a System.Drawing.Size and another property that returns a System.Drawing.Icon.

My other challenge is that my Icon property returning System.Drawing.Icon is simply accessing a child control with my own user control and exposing it to the user, so I want to pass through the DefaultValueAttribute defined by that.

erpPoSErrorProvider in the sample code is a System.Windows.Forms.ErrorProvider control.

Answers welcome in VB.NET or C#.
''' <summary>
''' Get/Set the System.Drawing.Icon that is displayed next to a control
''' when an error description string has been set for the control.</summary>
<System.ComponentModel.Description("Get/Set the System.Drawing.Icon that is displayed next to a control when an error description string has been set for the control."), _
 System.ComponentModel.Category("Appearance"), _
 System.ComponentModel.DefaultValue("(Icon)"), _
 System.ComponentModel.Browsable(True), _
 System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Always), _
 System.ComponentModel.Localizable(True)> _
Public Property Icon() As System.Drawing.Icon
	Get
		Return Me.erpPoSErrorProvider.Icon
	End Get
	Set(ByVal value As System.Drawing.Icon)
		Me.erpPoSErrorProvider.Icon = value
	End Set
End Property

Open in new window

Comment
Watch Question
Commented:
This problem has been solved!
Unlock 2 Answers and 13 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE