I have sub-classed the ultragrid so that we can add custom functionality. I've added a property ActiveObject that will allow me to data-bind to the ListObject of the active row. I've overridden the OnActiveRowChange to change the ActiveObject property. My problem is that I can't raise the PropertyChanged event without having a propId and as a result I cannot achieve two way binding. How do I go about raising this event so that I can update my object when the active row changes.
The part I'm stuck on is this:
OnPropertyChanged(New Infragistics.Win.PropertyChangedEventArgs(New Infragistics.Shared.PropChangeInfo(Me,[*******],Nothing))
Thanks in advance!
Hi,
You can't use the existing enum for the grid's PropertyIds, but you don't have to. The event args will take any enum value. So you can create your own enumeration and pass in whatever value you want.
The PropertyChanged event on INotifyPropertyChanged uses a property name property as a string. I don't understand how to signal that my custom property has changed using this enum. Could you elaborate on this?
The grid's PropertyChanged notification has nothing to do with INotifyPropertyChanged and the grid does not implement that interface.
The PropertyChanged event on the grid (or any of the Infragistics WinForms controls) is a sort've catch-all. It's used mainly to notify the design-surface that something has changed on a sub-object of a control. It can also be used in cases where there is no specific event for a change that you want to trap for.
If you are deriving your own control from the grid, there is no need for you to fire this event.
So I'm really not sure what you are trying to do here. What problem are you trying to solve?
Mike,
Thanks for the response and sorry for the confusion. I am using databinding and this is exactly what I was looking for.
Hi Derek,
Here's where you lost me.
Derek Engel said:We use two way binding for all of our controls so what I would like to do is set up a binding to this property.
I'm not sure what you mean by "two way binding". If you mean you are using WinForms DataBinding, then what exactly are you binding and what are you binding it to?
Again, the PropertyChanged event on the grid is NOT an implementation of the INotifyPropertyChange interface. This interface did not exist when the grid was introduced and this even has been around since the original release of the Infragistics WinForms controls.
If you are using DataBinding, then you are correct - the DotNet BindingManager needs to be notified when a property changes. It does this in one of two ways:
1) It looks for an event in the form of "{propertyName}Changed"
2) It uses the INotifyPropertyChange interface.
Either way, the PropertyChanged event of the grid will not have anything to do with it. Since there is no ActiveRowChanged event on the grid, I'm not sure how any of this can be working, so I must still be confused about what you are binding and what you are binding it to.
If you added a new property to your derived grid called ActiveObject, and you are using DataBinding to bind to this property, then the thing to do would be to add an "ActiveObjectChanged" event to the grid. Or, you could implement INotifyPropertyChanged on the grid and raise that notificaiton. You should be able to do this because the interface's PropertyChanged event does not have the same signature as the existing PropertyChange event.
I want to make a property called ActiveObject on my sub-classed grid. In order for this property to refresh I am updating it when the active row changes and when it does I make ActiveObject = Row.ListObject. Conversely, I can set ActiveObject and when I do the active row should change to the row that has the ActiveObject as its ListObject. This all works if I explicitly set the property in the code. We use two way binding for all of our controls so what I would like to do is set up a binding to this property. When I do this the active row changes just fine when the data-bound property changes.
What is not working is my bound property is not updating when the active row changed and ActiveObject changed for example when a user clicked on a different row.
Its my understanding that the .Net framework needs to be notified that the ActiveObject changed and that is why my bound property does not refresh when ActiveObject changed. That is why I was trying to use your OnPropertyChanged routine. Is there another way of notifying that this property changed or am I on the wrong track thinking that this is the problem?