Help with user control DefaultValue

P

Paul

I'm creating a user control with a DataGridView in it. In setting the
DefaultValue for some of the properties I had to use code like the
sample below:

<DefaultValue(GetType(System.Windows.Forms.ScrollBars), "3"),
Description("The type of scroll bars to display for the
EnhancedDataGridView control.")> _
Public Property ScrollBars() As System.Windows.Forms.ScrollBars
Get
Return DataGridView1.ScrollBars
End Get
Set(ByVal value As System.Windows.Forms.ScrollBars)
DataGridView1.ScrollBars = value
End Set
End Property

That works correctly. How do I set the DefaultValue for objects.
Below is an example. What would I replace the "???" with?

<DefaultValue(GetType(DataGridViewCellStyle), "???"), Description
("The default cell style applied to odd-numbered rows.")> _
Public Property AlternatingRows() As DataGridViewCellStyle
Get
Return DataGridView1.AlternatingRowsDefaultCellStyle
End Get
Set(ByVal value As DataGridViewCellStyle)
DataGridView1.AlternatingRowsDefaultCellStyle = value
End Set
End Property
 
C

Cor Ligthert[MVP]

Paul,

You set the default value of your usercontrol in the constructor of the
class, which can be as well in the base class of your usercontrol.

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top