Access ComboBox internal data values


Author
Message
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
Thanks!

Edhy Rijo

Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
They won't be the name of the columns in the combo box.  There will be 2 different columns (just put a break point in your code and look at the columns).  There will be a display and a value column (I think) but it gives you the contents of the combo.  The BO that was used to generate the contents of the BO is long gone by this point, so if you want to get back to that you will have to manually populate your own combo.
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
I hate to keep coming back with this, but it is not finding any of the columns I setup in the combox.

CType(Me.cboItemName.DataSource, DataTable).Rows(Me.cboItemName.SelectedIndex).Item("ItemPrice")

Here is the DataTable which only shows 3 columns and the column I would like to see "ItemPrice" its value is in the DropDown column:

I already implemented the method of using another BO for lookup, but if this can work, then it will be easier to maintain and re-use in other forms.

Edhy Rijo

Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Sorry I was going quickly and didn't totally flesh out the properties.  It is just a data table so it would look like this:

CType(MyCombo.DataSource, DataTable).Rows(MyCombo.SelectedIndex).Items("MyField")

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
Trent L. Taylor (09/22/2008)
You don't need access to the internal BO.  The internal BO is dead and gone once the combo is loaded.  But you have everything that you need right there in the data source.  When the BO is created and comes back, it is just executing the fill, using the parms specified, and the settings a DataTable to the DataSource of the combo.  So if you want to get to the datatable, just do this:

CType(MyCombo.DataSource, DataTable).Item("MyField")

Hi Trent,

Thanks for the info, but when testing your code above, I got an error that there is not Item property.  I have tried several ways to get access to any of the field values in the combo, but none worked.

Could you  please post the correct syntax to reference the combo field values?

Edhy Rijo

Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
You don't need access to the internal BO.  The internal BO is dead and gone once the combo is loaded.  But you have everything that you need right there in the data source.  When the BO is created and comes back, it is just executing the fill, using the parms specified, and the settings a DataTable to the DataSource of the combo.  So if you want to get to the datatable, just do this:

CType(MyCombo.DataSource, DataTable).Item("MyField")

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
Greg McGuffey (09/19/2008)
If I recall correctly, that BO is created and destroyed during the fill. It isn't persisted at all. However, that is the beauty of the CopyDataFrom method, when you need to persist the data for other reasons! BigGrin

Hi Greg,

I finally had the chance to play with this, even though I have done this a lot of time with the listviews and like you said, it does work nicely, but it would do a very good enhancement to get access to the internal combobox BO. 

Anyway here is the code I am using from the 2 comboboxes to illustrate this functionality:

Private Sub cboItemType_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboItemType.SelectedIndexChanged

     '-- Filter the cboItemName combobox data with the following parameters:

     ' Pass the PrimaryBO EditingState to filter out Active records if needed.

     ' The name of the Inactive Status field

     ' The ItemType value

     ' And the Appliance used.

     Me.BizItems_Lookup.Clear()

     Me.BizItems_Lookup.FillByActiveRecords(Me.bizSC_AppliancesItems1.EditingState, "ItemIsInactive", Me.bizSC_AppliancesItems1.ItemType, Me.BizSC_Appliances1.FK_Appliances)

     Me.cboItemName.Requery()

End Sub

 

Private Sub cboItemName_ListPopulating(ByVal e As MicroFour.StrataFrame.UI.ListPopulatingEventArgs) Handles cboItemName.ListPopulating

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

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

End Sub

 

Private Sub cboItemName_DropDown(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboItemName.DropDown

     If bizSC_AppliancesItems1.Count > 0 Then

          Me.cboItemName.Requery()

     Else

          Me.cboItemName.Items.Clear()

     End If

End Sub

 

Private Sub cboItemName_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboItemName.SelectedIndexChanged

     If Me.BizItems_Lookup.Count > 0 Then

          If Me.BizItems_Lookup.SeekToPrimaryKey(Me.bizSC_AppliancesItems1.FK_Items) Then

               Me.bizSC_AppliancesItems1.ItemPrice = Me.BizItems_Lookup.ItemPrice

          End If

     End If

End Sub



Edhy Rijo

Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.3K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
If I recall correctly, that BO is created and destroyed during the fill. It isn't persisted at all. However, that is the beauty of the CopyDataFrom method, when you need to persist the data for other reasons! BigGrin
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 Greg,

Thanks, it does make sense, even though it would be nice to have access to the internal BO used by the combobox to get other columns values.

Edhy Rijo

Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.3K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Another idea might be to use a form level BO that would hold the data needed to both fill the combo and to also provide the values for your other needs. You'd then fill the BO at the appropriate time and use CopyDataFrom method to fill the combo. This would allow you to put only the data needed in the combo for display but still have any data required (in the BO) for other uses. When the user selects a value, you'd just SeekToPrimaryKey to get the other values.



If I'm remembering this correctly, if the combo is filled via a BO method, then the items are DataRowView objects, with just two columns, display and value. You could probably figure out how to parse a multi-column combo, but seems like a lot of work when you could just be using a single BO to fill the combo and get the other values you need. In any case, this is what I've done in similar situations.



Hope that helps!
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