How Can I Populate my ListView from the Results of a Browse Dialog


Author
Message
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Sounds good Smile
Marcia G Akins
Marcia G Akins
StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)
Group: StrataFrame Users
Posts: 322, Visits: 529
Trent L. Taylor (10/10/2008)
The ListView is a lighter control and geared for this very thing.  The method that you want to use is the CopyDataFrom (as mentioned earlier).  A ListView (or any SF list for that matter) does not keep an instance of the BO that you specify in the PopulateDataSourceSettings property, but rather uses that and the method that you specify to populate the list and then disposes of that object.  So in this case, you wouldhave a BO on the form that is the "real" BO that you populate.  Then in the ListView you will call the CopyDataFrom method.  This same BO would be the BOToPopulate on the BrowseDialog which gets populated on the way back from the Browse.  Then finally, the ListPopulating event of the ListView would be handled to supply the parms to the CopyDataFrom method:

e.Parameters(0).Value = MyBOInstance
e.Paramteres(1).Value = BusinessObjectCloneType.ClearAndFillFromDefaultView

Hi Trent.

 

Thanks so much for the detailed explanation. That makes everything crystal clear. I will definitely be using the listview in the future

Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
The ListView is a lighter control and geared for this very thing.  The method that you want to use is the CopyDataFrom (as mentioned earlier).  A ListView (or any SF list for that matter) does not keep an instance of the BO that you specify in the PopulateDataSourceSettings property, but rather uses that and the method that you specify to populate the list and then disposes of that object.  So in this case, you wouldhave a BO on the form that is the "real" BO that you populate.  Then in the ListView you will call the CopyDataFrom method.  This same BO would be the BOToPopulate on the BrowseDialog which gets populated on the way back from the Browse.  Then finally, the ListPopulating event of the ListView would be handled to supply the parms to the CopyDataFrom method:

e.Parameters(0).Value = MyBOInstance
e.Paramteres(1).Value = BusinessObjectCloneType.ClearAndFillFromDefaultView

Marcia G Akins
Marcia G Akins
StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)
Group: StrataFrame Users
Posts: 322, Visits: 529
Greg McGuffey (10/09/2008)
Of course, if the datagridview is working, you might not want to mess with it, but it is very easy to populate a listview from a BO...once you figure it out! BigGrin

My philosophy is "if it ain't broke, don't fix it Tongue

But I will keep your exellent advice handy for the future.

Thanks again.

Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.3K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
You need to set the MethodToExecute to CopyDataFrom, use the business layer version.



Setup handler on CurrentTableRefilled on the BO in question, call requery of listview.



Add handler for the listview's ListPopulating and set the two params needed for CopyDataFrom, the first is the BO the second is an enum indicating how to fill listview from bo.



Of course, if the datagridview is working, you might not want to mess with it, but it is very easy to populate a listview from a BO...once you figure it out! BigGrin

Marcia G Akins
Marcia G Akins
StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)
Group: StrataFrame Users
Posts: 322, Visits: 529
Hi Greg.

Greg McGuffey (10/09/2008)

Hope that heads you in the right direction (or is so wrong somebody smarter will quickly correct me Pinch )

Just as an FYI, the only reason that I was going to use the listview was that it looked like it might be easier to put an image in the first column. Instead, I went to a DataGridView and added an unbound image column. I put this code in the BrowseDialogClosed() event handler and it worked just fine:

// Set up the icons for the traffic lights

if (!boViewTracking.IsEmpty)

{

foreach (DataGridViewRow loRow in grdViewTracking.Rows)

{

int tlINT = Convert.ToInt32(loRow.Cells["TL"].Value.ToString());

loRow.Cells["TrafficLight"].Value = imgViewTracking.Images[tlINT];

}

}


Marcia G Akins
Marcia G Akins
StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)
Group: StrataFrame Users
Posts: 322, Visits: 529
Greg McGuffey (10/09/2008)
I'm not super familiar with the BrowseDialog, but I'm guessing you'd drop a BO of the appropriate type on the form, drop a browsedialog on the form, setup the browse dialog to populate that BO when the user selects something, then setup the listview to CopyDataFrom that BO. Finally, handle the BO's CurrentTableRefilled event and requery the listview.

Hope that heads you in the right direction (or is so wrong somebody smarter will quickly correct me Pinch )

The browse dialog is working just fine. I have the ListView set up as bound to the same BO that the browse dialog is populating. But listview does not get populated. The Requery() method wants to call a method on the BO to populate it but that BO has already been poulated by the browse dialog Rolleyes  I just want to tell the listview to go populate itself from the BO that was populated by the browse dialog.

Thanks for trying to help.

Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.3K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
I'm not super familiar with the BrowseDialog, but I'm guessing you'd drop a BO of the appropriate type on the form, drop a browsedialog on the form, setup the browse dialog to populate that BO when the user selects something, then setup the listview to CopyDataFrom that BO. Finally, handle the BO's CurrentTableRefilled event and requery the listview.



Hope that heads you in the right direction (or is so wrong somebody smarter will quickly correct me Pinch )



Marcia G Akins
Marcia G Akins
StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)StrataFrame User (496 reputation)
Group: StrataFrame Users
Posts: 322, Visits: 529
The title says it all. Is there a simple way to let the browse dialog populate my listview?

Thanks!

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search