Reputation: 168
I feel that it's something elementary but I can't find out how to add to class commands for PropertyGrid.
There is a sample class (the real classes are much more complex, but I need only the simplest example to implement the required functionality)
Public Class SampleClass
Public Const DefValue = 1
Public Property Value1 As Integer = DefValue
Public Property Value2 As Integer = DefValue
Public Sub Reset()
Value1 = DefValue
Value2 = DefValue
End Sub
End Class
Used In the sample form:
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()>
Partial Class Form1
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()>
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()>
Private Sub InitializeComponent()
Me.PropertyGrid1 = New System.Windows.Forms.PropertyGrid()
Me.SuspendLayout()
'
'PropertyGrid1
'
Me.PropertyGrid1.Location = New System.Drawing.Point(242, 98)
Me.PropertyGrid1.Name = "PropertyGrid1"
Me.PropertyGrid1.Size = New System.Drawing.Size(294, 250)
Me.PropertyGrid1.TabIndex = 0
'
'Form1
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(7.0!, 15.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(800, 450)
Me.Controls.Add(Me.PropertyGrid1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
Friend WithEvents PropertyGrid1 As PropertyGrid
End Class
An instance is attached to PropertyGrid by the next piece of code:
Public Class Form1
Private Sample As New SampleClass
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
PropertyGrid1.SelectedObject = Sample
End Sub
End Class
The goal is to have a link that resets the contents of the instance at bottom of PropertyGrid like in the picture below, I presume that some attribute for a class is required but can't find what attribute.
Thanks for any advice.
Upvotes: 0
Views: 152