Populate ComboBox when BO needs a datasource key


Author
Message
Jason Seidell
Jason Seidell
StrataFrame User (153 reputation)StrataFrame User (153 reputation)StrataFrame User (153 reputation)StrataFrame User (153 reputation)StrataFrame User (153 reputation)StrataFrame User (153 reputation)StrataFrame User (153 reputation)StrataFrame User (153 reputation)StrataFrame User (153 reputation)
Group: Forum Members
Posts: 59, Visits: 180
I'm trying to figure out how to populate a combo box but I need to be able to set a DatasourceKey in the autopopulate settings and cannot.  When I try to manually populate the control I get data but as soon as you select an item the entire form locks and you cannot set focus to any other controls.  I'm completely lost as to why the combobox locks the form.

I'm frustrated that I cannot set the DatasourceKey for the population business object, and that I cannot find any examples for manually populating a business object.  All the documentation says to 'search for combobox population', and a vague reference to needing a datatable but no specifics for required fields.  Which seems odd since you populate a combobox with objects not datatables, or is there some interface the combobox items needs to support?

Jason

Jason Seidell

Programmer/Analyst

Infinedi

Replies
Jason Seidell
Jason Seidell
StrataFrame User (153 reputation)StrataFrame User (153 reputation)StrataFrame User (153 reputation)StrataFrame User (153 reputation)StrataFrame User (153 reputation)StrataFrame User (153 reputation)StrataFrame User (153 reputation)StrataFrame User (153 reputation)StrataFrame User (153 reputation)
Group: Forum Members
Posts: 59, Visits: 180
Well I at least found a good example on MSDN of how to populate a combo-box with items and get it to use the SelectedValue property for binding to the SF BO.   http://msdn.microsoft.com/en-us/library/system.windows.forms.listcontrol.valuemember.aspx

First I created a class to hold my items

Public Class ComboBoxItem(Of T)

Private _description As String

Private _value As T

''' <summary>

''' Initializes a new instance of the ComboBoxItem class.

''' </summary>

Public Sub New()

_description = String.Empty

End Sub

''' <summary>

''' Initializes a new instance of the ComboBoxItem class.

''' </summary>

Public Sub New(ByVal Description As String, ByVal Value As T)

Me.Description = Description

Me.Value = Value

End Sub

Public Overrides Function ToString() As String

Return String.Format("{0} ({1})", Description, Value)

End Function

Public Property Description() As String

Get

Return _description

End Get

Set(ByVal value As String)

_description = value

End Set

End Property

Public Property Value() As T

Get

Return _value

End Get

Set(ByVal value As T)

_value = value

End Set

End Property

End Class

Then on Form Load I run a function to populate

Dim elecPayers As New Infinedi.BO.Processing.Enrollment.ElectronicPayer_BO()

elecPayers.DataSourceKey = enrollmentDS.DatasourceKey

elecPayers.FillAll()

Dim elecPayerList As New ArrayList()

 

For i As Integer = 0 To elecPayers.Count - 1

elecPayers.MoveAbsolute(i)

elecPayerList.Add(New ComboBoxItem(Of Integer)(elecPayers.Name, elecPayers.ElectronicPayerID))

Next i

 

cmbElectronicPayerId.DataSource = elecPayerList

cmbElectronicPayerId.DisplayMember = "Description"

cmbElectronicPayerId.ValueMember = "Value"

So I'm at least to a point where I can move on and get it working, but I would still like to know why there isn't a property or field in the PopulationDataSourceSettings() to let me set the DatasourceKey instead of defaulting to a '' datasource key.

Jason Seidell

Programmer/Analyst

Infinedi

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



Couple of thing to clarify...



Combobox does not use a data source key, the key is assigned to the business object which is the one responsible to get the data. With this in mind this is how I setup my comboboxes:

1.- I drop an instance of the BO which will be used in the combobox.

2.- In the combobox set the following properties as follow:

a: PopulateOnFormLoad = Manual

b: PopulationDatasourceSettings:

i: Method to Execute: CopyDataFrom(BuisnessLayerBase,BusinessCloneDataType)

3.- In the ListPopluating add code to copy the data from the form's bo to the combo

Private Sub cboCustomerName_ListPopulating(ByVal e As MicroFour.StrataFrame.UI.ListPopulatingEventArgs) Handles cboCustomerName.ListPopulating

e.Parameters(0).Value = Me.BizClientesVFP1

e.Parameters(1).Value = MicroFour.StrataFrame.Business.BusinessCloneDataType.ClearAndFillFromCompleteTable

End Sub


Now, you need to manually at some point fill the form's bo with the correct data, then just requery() the combobox.



Make sure you use the desired DataSourceKey in the BO class or instance in the form.


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