StrataFrame Forum

Grid Control

http://forum.strataframe.net/Topic9107.aspx

By Sarosh - 5/27/2007

Hi!

How come I don't see a Grid Control in the StrataFrame toolbox?

I am missing something?

Sarosh

By Ivan George Borges - 5/27/2007

Hi Sarosh.

You can just use a standard .NET GridView control, or a third-party one.

Then, drop a BusinessBindingSource onto your form to allow native data binding. Have a look at the Help File, under :

Application Framework / UI Layer / Controls / Business Binding Source

Hope it helps.

Cheers.

By Trent L. Taylor - 5/27/2007

Ivan is correct.  There is no need for us to create a grid of our own since you can use any grid product that you like, including the standard .NET grid.  I recommend looking at the BusinessBindingSOurce sample that comes with StrataFrame.  This will give you a much better understanding of how to use a grid with StrataFrame.
By Sarosh - 5/28/2007

Hi!

Ok but in that case why have the other controls like the Checkbox, button ListBox in the toolbox?

Does it not make sense to subclass the DataGridView and put it in the toolbox even if nothing else added to the subclass?

Sarosh

By Trent L. Taylor - 5/28/2007

Ok but in that case why have the other controls like the Checkbox, button ListBox in the toolbox?

Because these classes implement our IBusinessBindable interface and provide native data binding.  It is one for one and these controls do not use the IBindingList interface like a grid or report will.  You can actually use the BusinessBindingSource to natively bind to any other 3rd party control as well but lose a bit of the SF functionality as it relates to automated enables/disables.

Does it not make sense to subclass the DataGridView and put it in the toolbox even if nothing else added to the subclass?

Not really....this is a nother beast entirely.  We could do this....but it would not buy you anything.  If you look at an Infragistics grid in the object browser and look at its derived type, it ultimately inherits off of a DataGridView. They have an entire team of developers that work on this one control...in fact, if you look at their source code they have comments that go back 7 years!  The only purpose of us inheriting a DataGridView is if we were going to overwrite base functionality and really extend the DataGridView.  After looking at all of the grids on the market, it is flooded with wonderful grids so it just did not make sense to do this....so we provided the BusinessBindingSource that allows you to tie into any of these 3rd party or standard .NET grids.

By Sarosh - 5/28/2007

Hi!

Thanks for the explanation.

I tried adding a .NET DataGridView on a Maintenance From inherited from "MicroFour.StrataFrame.UI.Windows.Forms.StandardForm" which has a MaintenanceFormToolStrip on it and also added a Business Object (generated by the Business Object Mapper) and a BusinessBindingSource, set the BusinessObject on the BBS to the BO and set the grid's DataSource to the BSS and then in the BO's ParentFormLoading called BO.FillAll() method.

Everything works fine, the grid show all the rows properly but the buttons on the toolstrip don't seem to work in sync with the grid. i.e. If I click the Next button on the ToolStrip it doesn't move the row in the grid. In fact no matter which button I click on the ToolbarStrip it seems to have no effect on the grid.

What am I doing wrong here?

Thanks

Sarosh

By Trent L. Taylor - 5/29/2007

rows properly but the buttons on the toolstrip don't seem to work in sync with the grid.

The MaintenanceFormToolstrip is not going to work with a Grid in this fashion.  The reason is that a BusinessBindingSource wraps a BO and implements the IBindingList interface which grids need in order to display and enumerate all of the rows in the data source at once.  The MaintenanceFormToolstrip interacts with the BOs directly and thus the normal interaction does not work the same.  If you look at the BusinessBindingSource sample that comes with the framework, you will see how to implement this type of functionality outside of the MaintnenaceFormToolstrip.

By StrataFrame Team - 5/29/2007

The BusinessBindingSource also implements the ICurrencyManagerProvider, which will sync the grid's active row with the Navigate() methods on the business object (used by the MaintenanceFormToolstrip).  Most likely, the grid has it's "SyncWithCurrencyManager" property set to false (I'm not sure of the property name on the grid, but it has something to do with synching with the CurrencyManager).
By Charles R Hankey - 5/29/2007

I have a DataGridView working on a form using BusinessBindingSource but can't seem to find any property of the grid relating to SyncwithCurrencyManager ( or anything re currency manager )



I have bound controls on the form for a single record and would like to refresh those control as the user navigates the ( readonly ) grid.



Ben - anymore clues on the property you mentioned?



Second part of question : can anyone point me to help re incremental searching in DataGridViews or the browse that comes with the SF browsedialog ? ( ala VFP - start typing in column and it seeks next matching record etc )



TIA



Charles
By Trent L. Taylor - 5/29/2007

If you will open up the BusinessBindingSource sample, it has the Next - Previous links that navigate the grid.  Have you looked at this sample to see how this is implemented?

can anyone point me to help re incremental searching in DataGridViews or the browse that comes with the SF browsedialog ? ( ala VFP - start typing in column and it seeks next matching record etc )

When 1.6.1 is released you can implement your own incremental search in a browse since the ListView is exposed through an InfoPanel control.  A ListView already has incremental search capabilities.

By Charles R Hankey - 5/29/2007

Yes, I looked at the example. I understand the handlers for the next etc under the grid. My question regards having the change of row in the grid cause bound controls on the form for an individual record refresh as the grid row changes.



In the sample I tried putting a couple of textboxes on the form below the grid, bindign them to company and last name and with your grid I got the expected behavior - i.e. as the row changed in the grid the bound control changed. Since they are looking at the same currentdatatable I would expect them to be in sync.



But I don't get that behavior in the form I am attempting. I have a standard maintenance form with customer fields. I setup a browsedialog which works fine to retrive records. So far so good.



So then I dropped DataGridView onto the form, set up a BusinessBindingSource to CustomersBO1 and set the datasource for the grid to the BBS. Now when I return from the BrowseDialog I have the right record in the bound fields, the right set of records in the grid, but they are not in sync and navigating in the grid does not refresh the displayed record.



( exception is if I scroll down the grid to EOF I have both a blank grid row and blank bound controls )



Remember, I'm a .NET idiot still thinking VFP Smile



I don't see anything in the sample in that respect and yet it works there as I would expect but not in mine. Any hints as to where I should look for what I have obviously left out ?



The only code i see in the sample that might (?) be relevant if I understood it is



'''

''' When the row changes within the grid, the Navigated event will fire

'''


'''

'''

Private Sub Customers_Navigated(ByVal e As MicroFour.StrataFrame.Business.NavigatedEventArgs) Handles Customers.Navigated

Me.lblRowIndex.Text = Me.Customers.CurrentRowIndex.ToString()

End Sub





TIA for you patience.






By Trent L. Taylor - 5/29/2007

they are looking at the same currentdatatable I would expect them to be in sync.

OK, first you need to understand that the CurrentDataTable does not actually do anything except house the data.  A DataTable does not have a record pointer, only the BO.  An SF BO keeps up with the "Current" record for you through the CurrentRowIndex property which can be accessed through the CurrentRow property as well.  When talking to a grid, it does not know what the current index of the business object is since it uses the IBindingList and ICurrencyManagerProvider interfaces and has its own internal pointer that is used. 

Depending upon which grid is used the "sync" will be slightly different.  One thing that you can do when the 1.6.1 release is made public is handle the BrowseDialogs AfterBrowse event and then sync it up yourself.  Right now you could use the CurrentDataTableRefilled on the BO that is populated through the Browse and add the same type of logic.

By Charles R Hankey - 5/29/2007

That first paragraph says a lot and reminds me I am a stranger in a strange land

Smile You guys have made all this look so friendly for us Foxers that it is easy to forget we ain't in Kansas anymore when it comes to data handling.



Currently, the part I am having the hardest time understanding is :



When I put two textboxes on the form of the BindingBusinessSource example and bind them to the BO fields, I get the behavior I wanted ( no button involved here ) Scroll through grid and textboxes update in sync



When I do it in my own form, I don't get that. I am starting to get the "there is no record pointer" thing, but when I change rows in the grid isn't some event raised that I can trap and put code in to "refresh" the textboxes or ... ? ( ignorance showing here, I know, but I think it is going to lead to getting the SF data binding a lot better than I do at present ) Aren't they still sharing the same currentdatatable to the point that if I did a navigate in the BO to the row represented in the grid the UI would show that record in the textboxes ?



Did you do something in the sample to make that happen and does it have anything to do with the code snippet I pasted in the previous message ?



Oh, and what/where is the "SyncWithCurrencyManager" property Ben makes reference to in Post 9138 of this thread and is it relevant here?



TIA
By Trent L. Taylor - 5/29/2007

You guys have made all this look so friendly for us Foxers that it is easy to forget we ain't in Kansas anymore when it comes to data handling.

Smile LOL...thanks....however, I have only dressed up as Dorthy once BigGrin

Did you do something in the sample to make that happen and does it have anything to do with the code snippet I pasted in the previous message ?

Yes.  If you look at the sample you can see that each of the links (i.e. Next, Previous) calls the Navigate method of the BO.  The grid will respect this through the BusinessBindingSource, but not the other way around.  If you want to go the other way around then you will have to handle the RowChanged event or something of that nature on the grid and navigate the BO to match the selected row.

Oh, and what/where is the "SyncWithCurrencyManager" property Ben makes reference to in Post 9138 of this thread and is it relevant here?

I am not sure it even exists on the standard DataGridView, I would have to look.  This exists on some 3rd party grids and that is probably to what he was referencing. 

By Charles R Hankey - 5/29/2007

Slowly this is starting to make sense. Are the samples documented/explained someplace in the Help for those of us who are really .NET challenged at this stage?



Yes. If you look at the sample you can see that each of the links (i.e. Next, Previous) calls the Navigate method of the BO. The grid will respect this through the BusinessBindingSource, but not the other way around. If you want to go the other way around then you will have to handle the RowChanged event or something of that nature on the grid and navigate the BO to match the selected row.




I know I'm being dense. I see that the linkss call the navigate method of the BO and that moves the currentrow in the grid, as well as the bound control below. It also works on my SF textboxes I dropped on. But what I am seeing seems to indicate that it does work the other way around in the sample, as putting the cursor in the grid and scrolling down has the same effect as using the links.



I don't get that behavior in my example. so perhaps having those link "methods" ( still haven't quite wrapped my head around how these behave differently than VFP methods ) there makes the difference and that the clicking of the link is not necessary to invoking their functionality, though I am not sure how they are bound to the rowchanging of the grid. I had assumed the link was causing the rowchange AND the change in the control, but now it seems the grid rowchange causes the change in the control however it is accomplished. Hmmmm Cool


By Trent L. Taylor - 5/29/2007

seems to indicate that it does work the other way around in the sample

You are right Blush I even wrote the sample BigGrin  Early on the this did not work and we made a change to support it...so sorry for the bad data there and for confusing the matter.

By Charles R Hankey - 5/29/2007

It must have been something I had done to my test app. ( I was trying to use a BOLibrary and had two child bos with relations set and bos on the form but as yet no controls or data retrieval methods - maybe that was screwing something up )



Anyway, created a new test app - simplest scenario possible - and navigating in the grid does indeed refresh bound controls outside the grid just as I expected it should ( and does in the sample ) with no coding required, so I broke something in my more complicated test app. I added a browsedialog to this one too, so that wasn't it. Must have been those child bos that weren't implemented.



I guess that's how we learn.



I tell. people the reason I love this job is that you learn more from making mistakes than you do from accidentally doing it right. ( it's a nice change actually - in a previous life I taught hang-gliding - getting it right the first time even by dumb luck was a big plus )



As Dilbert says "Creativity is allowing yourself to make mistakes - art is knowing which ones to keep" BigGrin



When is the next training class ? And do you happen to have any more training vids for Stratatrain buyers laying around you might want a beta tester for ? ( I am often used as a test for those who want to 'fool-proof' training material )




By Trent L. Taylor - 5/30/2007

a previous life I taught hang-gliding - getting it right the first time even by dumb luck was a big plus

ROFL....yeah I would think that was a HUGE plus! BigGrin

When is the next training class ?

We are working on the dates right now.  We will try to get those posted very soon and we will definitely let you know!

And do you happen to have any more training vids for Stratatrain buyers laying around you might want a beta tester for ?

There is a lot of work going on around this subject right now, so just hang on a little bit and I think you will be pleased with what is coming out.