Using treeviews

Using treeviews

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


rossl123 posted on Thursday, March 08, 2007

I am in the habit of using treeview controls on my windows forms, which in the past have worked fine for presenting read only data. Lately I have built a form that accepts input using a number of treeview controls, and I have run into a myriad of problems. My number one problem at the moment is this...

When you use a treeview control  on a windows form you have to accept the fact that you cannot bind it to the underlying data object, you have to synchronise the data manually, which you can easily do using events raised on the control. What you don't get though is an event raised on the form to say it has been changed.

Using the standard technique of binding the IsDirty checkbox control to the IsDirty property of the BusinessBase class doesn't work because the event doesn't occur, so my Cancel and Save buttons don't get enabled. Trying to work around the problem I thought I would try forcing the class to 'MarkDirty' on every change to the treeview control, but that didn't help, so I tried forcing the IsDirty checkbox to Checked, but that doesn't help either.

Why is this? Why do my Save and Cancel buttons not get enabled? Is there anyway around this problem? Am I missing something?


jhw replied on Friday, March 09, 2007

Here is a trick I use under different circumstances.  Never tried it with a tree view.

Create another simple object that exposes a single property such as a string. Bind it to the cxIsDirty and to a text box control with size = 0,0. When you respond to a tree view event, set the value of the tbox control so that the secondary object takes care of refreshing the page.

maurera replied on Friday, March 09, 2007

For what its worth, I was able to get the infragistics Tree View to bind to our business objects.  There seems to be a bit of Voodoo involved if your object(s) is(are) Hierarchical in nature, and there are some things you can't do (or at least I haven't been able to find a way) while data bound.

celidon replied on Monday, March 19, 2007

Maurera, would you have a simple example of how you achieved the Infragistics tree view binding to business objects?  I have a need to do the exact same thing and use Infragistics components as well.

Thanks!

Copyright (c) Marimer LLC