By Thomas Holste - 9/1/2011
Hi there,
in an app I have a panel with a toolstrip (and some toolstrip-buttons), a datagridview and some textboxes.
There is a BO (called MessidentBO) and a Business Binding Source to which the BO ist bound. The BBS is used as datasource for the datagridview and the textboxes. In the cmdNew-Button I have the following code:
Me.lEditmode = True
Me.DGVWL.Enabled = False ' Datagridview disabled
Me.cmdwlneu.Enabled = False
Me.cmdwledit.Enabled = False
Me.cmdwlsave.Enabled = True
Me.cmdwlundo.Enabled = True
Me.cmdwldelete.Enabled = False
Me.bbsmessident.BusinessObject.Add()
Me.bbsmessident.BusinessObject.Edit()
Me.TGBWL.Enabled = True ' Themed Group Box Enabled where the textboxes reside
Me.TxtMIIdent.Focus()
But this does not work. A new record is append, but the "record pointer" (If I can use this term) is not set to the new record but stays on the one selected in the Grid.
What really makes me wondering, is that I use the same kind of code in another app and there it works fine!
I've been comparing the two pieces of code and the properties of the used elements but I can not find the difference.
Has anybody a tip for me what I might have been missing?
Thanks in advance
Thomas
|
By Ivan George Borges - 9/1/2011
Hi Thomas.
Is the BO the form's primary business object? Are the text controls bound to the BO?
|
By Thomas Holste - 9/5/2011
Hi Ivan,
yes, the textcontrols are bound to the bbs too. And in one of two cases (I have 2 panels with the
same functionality, but for different BOs) the BO is the primary BO of the form.
Best regards
Thomas
|
By Thomas Holste - 9/5/2011
Hi Ivan,
in an older forum-message I found the hint to refresh the grid after the add, but this does not help too.
Best regards
Thomas
|
By Ivan George Borges - 9/6/2011
Thomas Holste (9/5/2011) yes, the textcontrols are bound to the bbs too.
Hi Thomas.
I am a bit confused here. Have you used the textboxes Properties window to set their BusinessObject property to a BusinessBindingSource? I think that is not possible. Do you think you could write a small sample using the StrataFrameSample database reproducing what you are trying to accomplish and post it here? This way we could take a look and try to help.
|
By Thomas Holste - 9/6/2011
Hi Ivan,
sorry, I did not want to confuse you. The textboxes are bound by the Databindungs/Text-Property to the Business-Bindungs-Source. The problem is not with the textboxes, which are synchronized in the right way but with the BBS which does not refresh the controls (The grid and the textboxes too). When I execute the above described code, a new record is appended, but the current row does not change (In another app, which is a bit different, this code works fine). To illustrate this behaviour, I have made a little test-app which uses your database. Just click the "new"-button and see what happens.
Thanks a lot for your help
Thomas
|
By Ivan George Borges - 9/7/2011
Hey Thomas. I had a look at it and posted here with some changes that made it work. Hope it helps.
Your textboxes were not bound the StrataFrame way. You were using the (DataBindings) and not setting the BusinessObject property nor the BindingField.
In your code, I changed places where you were dealing with the BBS, and set everything to the BO. Have a look at it and see if it makes sense to you, I have commented the lines where I changed things.
Also, I would like to recommend you to go through the Tutorials in the help file in case you haven't done so yet.
|
By Thomas Holste - 9/7/2011
Hi Ivan,
thanks a lot for your help. I checked your changes and they work but there is something left.
What I expected (and what I did in another app is that, when I add a new record, grid and textboxes are synchronized, that means, that executing the add-code changes also to the new, still blank record in the grid. The new data is entered, after saving the grid points to the new record.
I have added to the sample a second form, which is now the start-form, which does not utilize the link-menu, the panel-manager and panels. This is the way I use it in an other app (where it works fine) and here it works now to. I changed it back to my code, but with your changes it would work the same way (Except that you use ME.Add which, like I understand ist uses the form's primary business object but I will have some panels for maintaing data from different tables).
So to me it seems that the problem is not caused by my way of binding the controls (btw:. I took from the Business Binding Sample where the grid and a corresponding label are both bound via BBS) but by the link-manager/panel-combination. You will see that everything works fine on the new form2.
Best regards
Thomas
|
By Ivan George Borges - 9/7/2011
What I expected (and what I did in another app is that, when I add a new record, grid and textboxes are synchronized, that means, that executing the add-code changes also to the new, still blank record in the grid. The new data is entered, after saving the grid points to the new record.
Strange, this is exactly what I got with your sample after I made the changes.
Glad you got it going!
|
By Thomas Holste - 9/7/2011
Hi Ivan,
sorry to say but I haven't got it going. My sample just shows that the Business Binding Source works right if the grid which uses the BBS is not placed on a panel like it was in the first example. I tested it a little further and added now to the working example a panel-manager and a page and placed the grid and the group-box woth the textboxes on it (The sample is attached). Guess what happens? It fails. To me it looks like a seroius bug in the business binding source component? If it is a bug, will it be fixed and when? Or is this limited by design and I have to redesign the interface. I hope you understand that the thought of redesigning the interface of an almost finished app really annoys me because it is really time-consuming.
Best regards
Thomas
|
By Ivan George Borges - 9/8/2011
Hi Thomas.
Find attached a video of your first sample, with the panel, working as I guess you expect. The only thing I did was to add a line in your New button click to navigate the grid to the newly added row. This is not a BBS responsibility, every different grid on the market will have its own way to do it. I didn't understand well what the bug would be, but maybe you are saying that a BBS wouldn't work on a panel? If so, I guess no, I haven't found any bug there, and I have BBS working in all different places through my applications, hundreds of BBSs.
This is how I navigated your grid:
'-- navigate the Grid dgvkunden.CurrentCell = dgvkunden.Item(0, dgvkunden.Rows.Count - 2)
Of course, there are many ways to skin a cat, so you would just have to find the best one that would fit your needs.
Cheers.
|
By Thomas Holste - 9/8/2011
Hi Ivan,
thanks for your help. At first it did not work but after changing
dgvkunden.CurrentCell = dgvkunden.Item(0, dgvkunden.Rows.Count - 2)
to
dgvkunden.CurrentCell = dgvkunden.Item(0, dgvkunden.Rows.Count - 1)
it works really fine
Best regards
Thomas
|
By Ivan George Borges - 9/8/2011
Glad it helped, Thomas.
|
|