Combo Box with Custom method


Author
Message
Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)
Group: StrataFrame Users
Posts: 430, Visits: 507
Hi Edhy and Greg....thanks again for your replies.

I'm happy that I understand the way Combos are populated now by Strataframe

Regards,

Gerard

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
Gerard O Carroll (10/28/2009)
If I wanted to set the parameter from another control, do I just



MyBoFillByValue("MYVALUE"); MyCombo.Reqyuery(); from the other control and change PopulateOnFormLoad to manual ?



This does not sound right as I am setting the MyValue in the ListPopulating event as well ?




You are right, it does not sound right. In my sample the parameter passed is a BO.Property value but it could be any variable you want to use. From other places you simple update that value and call the combobox.Requery() which will run the assigned method and will look for the parameter value in the ListPopulating.



I know it is hard to believe it is that simple w00t

Edhy Rijo

Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.3K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Gerard,



You're getting there. There are two ways to provide parameters to the fill method setup in the population settings:



1. (suggested) Handle the ListPopulating event (as Edhy showed and you've got working). If this is used, then every time the Requery method is called with no parameters (see below), this event will be fired and the parameters provided to the fill method.



2. Provide the paremeters to the combo's Requery method:



Me.MyCombo.Requery("MyValue") '-- where "MyValue" is the parameter needed by your fill method




You can pass whatever your fill method needs to Requery method directly. However as mentioned, handling the ListPopulating event is preferred as this isolates setting parameter(s) to a single place.



That's how it gets filled using a fill method.



The PopulateOnFormLoad property determine if the combo is loaded during the FormLoad event, as controlled by the InitializePriority property (lower numbers get loaded first). If set to manual, you must call the Requery method to fill it. However, at any time, you can call requery to refill it. This is very common.



I hope that is starting to make sense!
Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)
Group: StrataFrame Users
Posts: 430, Visits: 507
Hi Edhy.

Thanks very much for that...Worked first time when I set the parameter in the list Populating event.

I am still trying to get my head around 'event' programming !!. If I wanted to set the parameter from another control, do I just

MyBoFillByValue("MYVALUE");    MyCombo.Reqyuery(); from the other control and change PopulateOnFormLoad to manual ?

This does not sound right as I am setting the MyValue in the ListPopulating event as well ?

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 Gerald,



Combobox and Listview have a ListPopulating event which is used to pass any information you need to the method used to populate the control.



Here is sample VB code on how to use that event:



Private Sub cboVehicleMake_ListPopulating(ByVal e As MicroFour.StrataFrame.UI.ListPopulatingEventArgs) Handles cboVehicleMake.ListPopulating

If Me.BizCustomers1.Count > 0 Then

e.Parameters(0).Value = Me.BizCustomers1.PK_Customers

Else

e.Parameters(0).Value = -1

End If

End Sub





In the above example, I am passing the primary key value of the bizCustomers1 BO, so as a rule before using any BO property I check the BO.Count > 0 to avoid any error, and if so, then pass a value I know will not exist like -1 or 0. Also keep in mind that the e.Parameters() is a collection of parameters that you can pass in case your method or any of the SF custom methods requires more than one parameter, so you can use e.Parameters(0).Value, e.Parameters(1).Value, etc.



Also when using combobox and listview you can choose to populate them at the form's load() event or manually to give you more control in case the data to be use to populate them depend on a previous selection in other combobox or any other control, and you simply call the control.Requery() to force the ListPopulating event to fire.



Good luck!

Edhy Rijo

Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)Advanced StrataFrame User (630 reputation)
Group: StrataFrame Users
Posts: 430, Visits: 507
I have a Combo Box on a form, based on a Business Object. In PopulationdataSourceSettings, I have the MethodToExecute as MyFillByCode. This is a Method I have set up in the Business Object which takes one parameter. In the PopuationDataSourceSettings, it comes up as MyFillByCode(String). What I want is something like MyFillByCode("MyValue") but can change the String.

Because the parameter is not set, the form gives an error on instantiation. Where/how do I pass the method the parameter.

The parameter will not change once the form is loaded. I am using the Combo Box to lookup a table with Codes and Descriptions and store all Codes and descriptions in one table (e.g. Countries, Areas, reps, Groups) . One of the fields in the table identify the type of Lookup, and this is the parameter I am trying to pass. I could have a no. of simular Combo Boxes on the same form , each one for a different lookup.

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