Torna al Thread
Imports System.Reflection
Public Class Form1
Dim ClsProva As New Class1
Dim modifica As Boolean
Private Sub Form1_Load() Handles MyBase.Load
PropertyGrid1.SelectedObject = ClsProva
modifica = False
End Sub
Private Sub PropertyGrid1_SelectedGridItemChanged() Handles PropertyGrid1.SelectedGridItemChanged
TextBox1.Text = PropertyGrid1.SelectedGridItem.Value
End Sub
Private Sub TextBox1_Enter() Handles TextBox1.Enter
modifica = True
End Sub
Private Sub TextBox1_Leave() Handles TextBox1.Leave
modifica = False
End Sub
Private Sub TextBox1_TextChanged() Handles TextBox1.TextChanged
If modifica = True Then
Dim cls_Pgrid As System.Type = (PropertyGrid1.SelectedObject).GetType
Dim Pgrid_selezionata As PropertyInfo = cls_Pgrid.GetProperty(PropertyGrid1.SelectedGridItem.Label)
Pgrid_selezionata.SetValue(PropertyGrid1.SelectedObject, TextBox1.Text, Nothing)
PropertyGrid1.Refresh()
End If
End Sub
End Class