ChildFormDialog-Question/Problem


Author
Message
Thomas Holste
Thomas Holste
StrataFrame User (360 reputation)StrataFrame User (360 reputation)StrataFrame User (360 reputation)StrataFrame User (360 reputation)StrataFrame User (360 reputation)StrataFrame User (360 reputation)StrataFrame User (360 reputation)StrataFrame User (360 reputation)StrataFrame User (360 reputation)
Group: StrataFrame Users
Posts: 144, Visits: 618
Hi there,

I have a perentform which contains a datagridview to present and seek customer-data

and use a childformdialog to open a child-window to edit a selected record.

This is the code in my parent-form



Dim cErr As String = ""

Me.KundenBO1.Edit()

If Me.ChildKundNeu.ShowDialog(False, Me) = DialogResult.OK Then

If KundenBO1.Save <> MicroFour.StrataFrame.Data.SaveUndoResult.Success Then

cErr = "Fehler beim Speichern!"

mymsgbox(cErr, 48, cProgtitle)

Else

cErr = "Satz gespeichert!"

mymsgbox(cErr, 64, cProgtitle)

End If

Else

cErr = "Abbruch"

Me.KundenBO1.Undo(MicroFour.StrataFrame.Business.BusinessUndoType.CurrentRowOnly)

mymsgbox(cErr, 64, cProgtitle)

End If



So far, so good. The first parameter in the constructor determines, if a record ist added (True) or edited (False). Now whe I edit a record I want enable the use to undo changes in the child-form without closing and opening it again. So I put an "Undo-Button" on the form and call the Undo-Method of the childform-BO which is set up in the BO-Translations of the childformdialog as the destination BO.



KundenBO1.Undo(MicroFour.StrataFrame.Business.BusinessUndoType.CurrentRowOnly)



But this leads to the following error (Translated from german):

"Invalid conversion from type DBNull to type string"

And this is where it happens:



Public Overrides Sub SetValue(ByVal component As Object, ByVal value As Object)

Select Case Me.Field

Case KundenBOFieldNames.KUNDENNR

DirectCast(component, KundenBO).KUNDENNR = CType(value, System.Int32)

Case KundenBOFieldNames.ANREDE

DirectCast(component, KundenBO).ANREDE = CType(value, System.String)



The last Directcast is where the error happens.

I wonxder now if I am doing something wrong or if this can not be done this way.

Thanks for your help

Thomas
Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Thomas,

If the data shown in the datagridview is presented to user as ReadOnly, then you could use a SF ListView which has build-in automation to show and manage a childformdialog, also you can easily color the rows based on the data conditions.
Or you can use the new StrataListView which is faster and more flexible than the SF Listview, it does not have the childform automation, but I posted a subclass version with some support for automation here: http://forum.strataframe.net/FindPost28459.aspx I even posted a VB sample project.

Also Trent posted a C# sample here: http://forum.strataframe.net/FindPost24981.aspx

Edhy Rijo

Edited 12 Years Ago by Edhy Rijo
Thomas Holste
Thomas Holste
StrataFrame User (360 reputation)StrataFrame User (360 reputation)StrataFrame User (360 reputation)StrataFrame User (360 reputation)StrataFrame User (360 reputation)StrataFrame User (360 reputation)StrataFrame User (360 reputation)StrataFrame User (360 reputation)StrataFrame User (360 reputation)
Group: StrataFrame Users
Posts: 144, Visits: 618
Hi Edhy,

thanks for your help. I want to use the grid because of the many abilities the datagridview offers. I tried the stratalistview which looks really nice but is to basic for me )and has it ever left the beta-status behind?). I use it in another project but in my recent project I want to use datagridviews because of the many possibilities they offer (For example, some other grids I will use need comboboxes and checkboxes instead of textboxes for presenting and editing grid-data and this seems to be far beyond the possibilities of the listview or the stratalistview. If this task is not to realise I will implement the child-windo wothout the childformdialog-control.

Best regards

Thomas
Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Thomas,

I understand your reason and agree with you on that.

Now I will try to help you with the current situation which I believe the problem is the error you are getting when doing the undo.  This could end up being a large thread so if after my response you don't get the issue fixed, it would be easier if you create a quick VB sample using the SF Database with a grid and a childform so I can help you out better.

Based on your explanation, you are passing some parameters to the child form just to see if you are Adding or Editing a record, right?  If so, you don't need to do that, once the BO is translated in the child form you can check the bo.EditingState and that will tell you if you are in Adding/Editing/Idle.

Now I guess you are getting the cast error because there is no record in the BO when you are trying to do the Me.KundenBO1.Undo(MicroFour.StrataFrame.Business.BusinessUndoType.CurrentRowOnly).  Make sure the Me.KundenBO1.Count is > 0

I would assume you have used the ChildFormDialog control before, but let me explain what the BO translation does, it will simply pass the current Parent BO instance into the Child Form, so you will be working basically with the same BO in its current EditingState and when you close the child form, whatever changes you have made to that BO it will be translated back to the parent form BO instance.  Knowing that, it is important to know that you should not move the BO.CurrentRowIndex or Fill the child form BO instance again or you will get all kind of weird errors.

I love the ChildFormDialog functionality and flexibility, so I use it constantly in all my applications with and without ListViews.


Edhy Rijo

Thomas Holste
Thomas Holste
StrataFrame User (360 reputation)StrataFrame User (360 reputation)StrataFrame User (360 reputation)StrataFrame User (360 reputation)StrataFrame User (360 reputation)StrataFrame User (360 reputation)StrataFrame User (360 reputation)StrataFrame User (360 reputation)StrataFrame User (360 reputation)
Group: StrataFrame Users
Posts: 144, Visits: 618
Hi Edhy,

I've traced the problem to a combobox-control. I had not set the population-propertie and after I did that, the error disappeared.

But another problem gas occured. I can now select an item from the dropdown-list but it is not displayed in the entry-part of the combo. When I then try to leacve the field I get the same dbnull-error. I am sure I missed some property-setting but haven't yet found out what.

I set the Binding-Field and business-object and the choose "Business Object" as population type. Afterwards I set up the populationdatasourcesetting by choosing the BO and its fill-method, its field to display and the three values for Display Member Format String ({0}), Dropdown Display Format ({0}) and the value member (Name of the field).

Best regards

Thomas
Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Thomas,

I am glad you are finding your way out Tongue

Now for the combobox list population, it is fairly simply, the key is that the field used in the Value Member should match the one used for binding in your form's BO.  In the sample image below, I have only one field in this table and it happens to be the same used as Display Member, but most of the time it is not.
http://forum.strataframe.net/Uploads/Images/75f1634a-ff01-415d-9e32-163d.png

Also on a side note, in the Business Object Mapper (BOM) make sure you are using setting the "NULL Value Option" to "Return Alternate on Null" for each field ex: Return 0 for Integers and String.Empty or "" for Strings.  I noticed that in some 3rd party controls like DevExpress grids it helps to do this.

Edhy Rijo

Thomas Holste
Thomas Holste
StrataFrame User (360 reputation)StrataFrame User (360 reputation)StrataFrame User (360 reputation)StrataFrame User (360 reputation)StrataFrame User (360 reputation)StrataFrame User (360 reputation)StrataFrame User (360 reputation)StrataFrame User (360 reputation)StrataFrame User (360 reputation)
Group: StrataFrame Users
Posts: 144, Visits: 618
Hi Edhy,

thanks again for your help. The problem was that I had to set tthe BindingFormat-Property to Text. Now everything seems to work.

Best regards

Thomas
Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Well, the BindingProperty for combobox should be set to SelectedValue no text, but if in your case is working is because something else may not be set correctly with the PopulationDataSourceSettings, see sample below:
http://forum.strataframe.net/Uploads/Images/f1ee4303-27e4-4748-b1a2-b5aa.png

Edhy Rijo

Thomas Holste
Thomas Holste
StrataFrame User (360 reputation)StrataFrame User (360 reputation)StrataFrame User (360 reputation)StrataFrame User (360 reputation)StrataFrame User (360 reputation)StrataFrame User (360 reputation)StrataFrame User (360 reputation)StrataFrame User (360 reputation)StrataFrame User (360 reputation)
Group: StrataFrame Users
Posts: 144, Visits: 618
Hi Edhy,

is your property-sheet-example from a combobox set to "dropdown-list"? My combobox ist set up as "dropdown".

All my settings look like yours, except for the Bindingproperty. When I set it to selectedvalue, all records which do not have the field in the customer-record filled, show up with the first value from the lookup-table and not as intended, with an empty entry.

Best regards

Thomas
Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Thomas Holste (7/26/2012)
When I set it to selectedvalue, all records which do not have the field in the customer-record filled, show up with the first value from the lookup-table and not as intended, with an empty entry.

You need to setup the TopMostItem properties of the combo in combination with the "NULL Value Option" setup in the BOM, in the image below I setup the field in the BOM to return 0 when NULL, so using the combobox.TopMostItem I can enter a description <Enter or Select Card Code> and then the value of 0 (zero) so when I get a NULL field it will show my description.  Look it in the help file for better explanation.

http://forum.strataframe.net/Uploads/Images/40c57c65-67c9-4ba9-8631-afe9.png

Edhy Rijo

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