How do you bind a CSLA Biz object to a List Control with Multi-select

How do you bind a CSLA Biz object to a List Control with Multi-select

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


SethSpearman posted on Wednesday, December 17, 2008

Hello,
I am developing a .NET 2.0 Winforms application using CSLA 3.05 (compiled to remove .net 3.0+ bindings).  I have gotten a BusinessListBase csla biz object successfully bound to a listbox control using the <object>BindingSource control as described in the VB 2005 Biz Objects book pages 494-495 (Project List - Select Project form). 

But one difference between what Rocky does there is that I want the user to be able to select MULTIPLE rows in the listbox.   To accomodate this I have added a SELECTED property to my Biz object child class and enabled the MultiSelect property on the list control.  (This SELECTED property is not data bound...it is just used at runtime)

Is there a way to create a DataBinding on the ListBox control that will bind to the SELECTED property of the Business Object child class.  Something list Me.MyListBox.DataBindings.Add("<NOT SURE>",myBizObject,"SELECTED").  I cannot figure out how or if this can be done.

IF not...what could I hook into a listbox control event and directly change that property on the child object.  Can anyone provide a code sample.

Thanks in advance for your help?

Seth B Spearman

ajj3085 replied on Thursday, December 18, 2008

Something doesn't sound right about adding a property to the business layer to support a UI concept (if the item is selected or not).  Does "selecting" an item mean anything business-wise?

SethSpearman replied on Thursday, December 18, 2008

Andy,

That is a valid question and point.  But in my case it "might" support a business requirement.  Specifically I want to mark a list of people as being in attendance in a meeting.  I want that "status" to be preserved between the opening of the form.  So the second time it opens the ones who are marked as present are STILL marked as present in teh form when it spins up again. 

Can it be done?

Seth


xxxJasonxxx replied on Thursday, January 08, 2009

Whoops....I just posted pretty much the same question a few days after you....

http://forums.lhotka.net/forums/thread/29557.aspx

Sorry, I will search a little hard next time before posting a "new" question.

Copyright (c) Marimer LLC