Std Data grid view and SF Toolstrip don't communicate with each other!


Std Data grid view and SF Toolstrip don't communicate with each other!...
Author
Message
Ben Hayat
Ben Hayat
Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)
Group: Forum Members
Posts: 374, Visits: 1.2K
Greg McGuffey (06/12/2007)
OK, so you are saying that when you use the BBS with a grid view and navigate the BO using some method (toolstrip or links) that the grid doesn't navigate?



I'd check out the properties of the grid. Maybe there is property that indicates the grid selection should change when the datatable current row changes and it's turned off???



I don't know much about ADO.NET, but I do know that BOs just wrap a datatable, and the BBS is bound via that datatable, so the grid changing selected rows is very likely just a .NET thing, not related to SF at all....just a guess.



Good luck!




Greg, check out my other post. Just found the problem!

..ßen
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.4K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
OK, so you are saying that when you use the BBS with a grid view and navigate the BO using some method (toolstrip or links) that the grid doesn't navigate?



I'd check out the properties of the grid. Maybe there is property that indicates the grid selection should change when the datatable current row changes and it's turned off???



I don't know much about ADO.NET, but I do know that BOs just wrap a datatable, and the BBS is bound via that datatable, so the grid changing selected rows is very likely just a .NET thing, not related to SF at all....just a guess.



Good luck!
Ben Hayat
Ben Hayat
Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)
Group: Forum Members
Posts: 374, Visits: 1.2K
Greg, my original question was really aimed at BBS and grid and got side tracked to Listview.



There is a sample called BusinessBindingSource which does exactly what I need to do.

You drop a BO on a form.

you drop BBS on the form and connect it to BO

You then put a grid on the form and connect it's data source to BBS.



On the sample it works and when I do this on my form, I see the data in grid but has no two way binding. I've looked every single property and don't see why. The sample has no code to force the two way binding.



Could someone point me to right direction.



Thanks!

..ßen
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.4K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
yep. It most likely won't be all the rows, just until it finds the correct one. BigGrin



There may be a better way. This works if the list is small.



Another possibility would be to keep a dictionary (created when you load the list initially) that tracks the list index to the PK. The PK would be the key, the index would be the value.
Ben Hayat
Ben Hayat
Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)
Group: Forum Members
Posts: 374, Visits: 1.2K
Greg;



Synching ListView to CurrentRow

Just handle the BO's Navigated event and select the appropriate item in the list view. I pretty sure the only way is to walk the items in the list view, checking the Tag to equal the pk of the current row. Maybe Trent/Ben has another/better method.




This is the tricky one! Are you saying that we need to iterate thru all the items of the list view to match the current row in BO table?

..ßen
Ben Hayat
Ben Hayat
Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)
Group: Forum Members
Posts: 374, Visits: 1.2K
Greg, thanks for you input;

Of course if this isn't what you are doing....never mind
This is exactly what I wanted to describe. A two way communication between listview/grid and toolstrip.

..ßen
Ben Hayat
Ben Hayat
Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)
Group: Forum Members
Posts: 374, Visits: 1.2K
Trent L. Taylor (06/12/2007)
If you will recall, we went over this in class in several different manners. Just use the CopyDataFrom method to use the data within the local instance versus a Fill method. SF comes with an advanced ListView sample that shows how to do this. Using this approach you only populate the BO on your form, use the CopyDataFrom method within the PopulationDataSourceSettings, and you will get the behavior you are looking for. This is what we do most of the time as well.




Hi Trent;



Yes I do recall from the class but couldn't find anything that shows both listview and toolstrip working both direction. I even looked at chapter 18 to get a better feel for it, but if you look at chapter 18, you see the listview does not respond to toolstip and vice versa.



I think Greg hit it right on the nail. A simple toolstip, listview and a few textboxes connected to BO

a) if user navigate on toolstrip, the list view moves too.

b) if user moves the listview, then the toolstrip gets moved to.



Now here is the strange part. There is a sample called "Binding Business Source" which works with grid. I don't see any code that creates the sync between the grid and toolstrip. However, when I duplicated that on my form, the grid and toolstrip don't sync up. This has puzzled me.



In one post Ben Chase had mentioned that BBS will do this behavior and that was my original point with grid.



Your input is much appreciated!


..ßen
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.4K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Trent posted faster than I did! BigGrin
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.4K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Ben (hayat)



If I understand your question, you have a maintenancetoolstrip, a listview, and some controls bound to a BO on a form. You want to navigate the BO that the controls are bound to using both the listview and the toolstrip. Likewise, when the toolstrip does the navigation, you want to change the selected item in the listview. There are several issues to deal with: loading the listview with the same data as the BO, synching the listview to the current row, updating the ListView when data in BO changes, and the one Trent provide a code sample for, synching the BO with the selected item in listview.



Loading ListView w/data from BO

The trick is to setup the listview to populate using the CopyDataFrom() method. Then handle the ListPopulating event of the list and set the two parameters of the CopyFromData method to the BO that the controls are bound to and the BusinessCloneDataType to ClearAndFillFromCompleteTable. This keeps the list and the bo the other controls are bound to in synch.



Synching ListView to CurrentRow

Just handle the BO's Navigated event and select the appropriate item in the list view. I pretty sure the only way is to walk the items in the list view, checking the Tag to equal the pk of the current row. Maybe Trent/Ben has another/better method.



Updating the ListView when the Data in the BO changes

You will also need to handle the appropriate events when the adding/removing/editing items in the BO and update the list (Requery it) and likely reselect the correct item. There may be a better way to do this. If the lists are small this way is fine.



Reusable code

Consider putting this code it into a component. The component can be dropped onto a form, then set its BO, its ListView and your done. The BO has a property to get the name of the primary key field. You can react to the BO and listview events in the component. Very handy.





Of course if this isn't what you are doing....never mind
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
If you will recall, we went over this in class in several different manners.  Just use the CopyDataFrom method to use the data within the local instance versus a Fill method.  SF comes with an advanced ListView sample that shows how to do this.  Using this approach you only populate the BO on your form, use the CopyDataFrom method within the PopulationDataSourceSettings, and you will get the behavior you are looking for.  This is what we do most of the time as well.
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