PropertyGrid PropertyValueChanged SetValue not working in .NET 4.0

  • Thread starter Thread starter Tim8w
  • Start date Start date
T

Tim8w

Guest
I have seen great examples here and had great hopes that it would work for our application. I need to catch a change in the GridItem and revert it under certain conditions. We are using VB.Net 2012 with .NET Framework 4.0. All the examples I have been able to find use the following code:

Code:

Dim iChangedItem = e.ChangedItem
Dim propertyName = iChangedItem.PropertyDescriptor.Name
Dim pInfo As _PropertyInfo = pgSetup.SelectedObject.GetType().GetProperty(propertyName)
pInfo.SetValue(pgSetup.SelectedObject, e.OldValue, null)

If I do this I get the following message from VisualStudio:

'null' is not declared. 'Null' constant is no longer supported. Use 'System.DBNull' instead.

If I use 'System.DBNull.Value' I get a different error:

Value of type 'System.DBNull' cannot be converted to '1-dimensional array of Object'

I have also tried 'Nothing", which VisualStudio is OK with but I get a runtime error of:

NullReferenceException was unhandled

Any ideas how I can get this to work? I know that there is a version with only 2 parameters in later versions of the .NET Framework, but as of today anyway, I cannot change the .NET platform for this program.
Tim

Continue reading...
 
Back
Top