PropertyChanged in UI

PropertyChanged in UI

Old forum URL: forums.lhotka.net/forums/t/4910.aspx


dtabako posted on Thursday, May 29, 2008

This may be something obvious that I'm missing but I'm trying to figure out how to get notification of a specific property changing within my databound UI. The specific issue is that I have a comboBox that needs to refresh its list based on the value within another text box. This seems like it would be a fairly common scenario so I feel like I'm missing something simple.

Thanks, Dennis

RockfordLhotka replied on Thursday, May 29, 2008

You can handle the CurrentItemChanged event on the bindingsource, though that won't tell you the specific property that was changed.

You can handle the PropertyChanged event on the business object itself, and that will provide you with the name of the property that changed (or a null or empty string if ALL properties should be considered changed).

dtabako replied on Thursday, May 29, 2008

Thanks Rocky. I had made an attempt to handle PropertyChanged in my UI previously but I must have messed something up. Got it working now though. Thanks a lot.

Dennis

AlexTTNET replied on Thursday, May 29, 2008

Why not handled:

ctl_BindingSourceListChanged for your control and then analyze :

 

If e.ListChangedType = System.ComponentModel.ListChangedType.ItemChanged AndAlso Not e.PropertyDescriptor Is Nothing Then

 

   '' 

   from here on you can check e.PropertyDescriptor.Name, that give you name of property, and then apply your logic.

 

End If

 

Alex

dtabako replied on Thursday, May 29, 2008

Thanks Alex,

That was the kind of thing I was trying to do after I messed up handling PropertyChanged on my UI. I was pretty sure there was a way to do it through the BindingSource I just couldn't find any examples. Since I fixed my issues with handling PropertyChanged and it works the way I want now, I'll probably stick with that. But I might give your way a try as well down the line.

Dennis

Copyright (c) Marimer LLC