好。我正在尝试取消或还原PropertyValueChanged事件中的更改。由于某些原因,我确定PropertyInfo为Nothing。这是完整的代码。关于PropertyInfo为什么什么都不返回的任何想法?
Private Sub pgSetup_PropertyValueChanged(sender As System.Object, e As System.Windows.Forms.PropertyValueChangedEventArgs) Handles pgSetup.PropertyValueChanged
Dim iChangedItem = e.ChangedItem
Dim propertyName = iChangedItem.PropertyDescriptor.Name
Dim pInfo As PropertyInfo = pgSetup.SelectedObject.GetType().GetProperty(propertyName)
pInfo.SetValue(pgSetup.SelectedObject, e.OldValue, Nothing)
End Sub
答案 0 :(得分:0)
在另一个论坛的用户的帮助下,这是最终成功的解决方案:
Dim propertyName = e.ChangedItem.PropertyDescriptor.Name
Dim pInfo As PropertyInfo = pgSetup.SelectedGridItem.Parent.Value.GetType().GetProperty(propertyName)
pInfo.SetValue(pgSetup.SelectedGridItem.Parent.Value, e.OldValue, Nothing)