1,105,344 Community Members

Changing default value of a property of a control (DataGridView).

Member Avatar
Light Poster
37 posts since Feb 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]

I am inheriting my own datagridview (say MyDataGridView) from the standard datagridview control. What I want is that certain properties of MyDataGridView should have a different default value than what its base have. For example, AllowUserToAddRows, AllowUserToDeleteRows, AllowUserToResizeRows properties should have the default values of False; so that when I drag MyDataGridView into a form in the IDE, the default values shown in the properties grid should be False. Later on, if I want to change them to True from the grid, they will be set accordingly. Is it possible somehow?
Please note that I don't want to set the default value of any custom property in MyDataGridView but the properties mentioned above that are derived from the base.

Member Avatar
Master Poster
765 posts since Jun 2006
Reputation Points: 88 [?]
Q&As Helped to Solve: 149 [?]
Skill Endorsements: 7 [?]

Unfortunately, those properties cannot be overridden.
Otherwise you could have have used the DefauleValue attribute.
You can however create your own properties with those names and use any default values you wish.

<DefaultValue(True/False)> _
Public Property AllowUserToAddRows() As Boolean
      Return MyBase.AllowUserToAddRows
   End Get
   Set(ByVal value As Boolean)
      MyBase.AllowUserToAddRows = value
   End Set
End Property
This article has been dead for over three months: Start a new discussion instead
Start New Discussion
View similar articles that have also been tagged: