Combobox


Author
Message
Michael Reese
Michael Reese
Advanced StrataFrame User (533 reputation)Advanced StrataFrame User (533 reputation)Advanced StrataFrame User (533 reputation)Advanced StrataFrame User (533 reputation)Advanced StrataFrame User (533 reputation)Advanced StrataFrame User (533 reputation)Advanced StrataFrame User (533 reputation)Advanced StrataFrame User (533 reputation)Advanced StrataFrame User (533 reputation)
Group: StrataFrame Users
Posts: 235, Visits: 1.6K
I am getting the above error. I am maintaining chart information in a table and one of the columns is Chartype. In my form, I have the following code to display charttypes in the combobox. When I load the form or select a chart type, I get the error above. The column is not null and I have taken care of that in the BOMapper.

My combobox is bindingfield is configure to the ChartType column and businessobject is the BOChartsInventory1.

********************************************************************************

Dim chartTypes As String() = System.Enum.GetNames(GetType(ChartType))

Dim ct As String

For Each ct In chartTypes

Me.cboChartype.Items.Add(ct)

Next ct

Me.cboChartype.SelectedValue = Me.cboChartype.Items(Me.cboChartype.FindString(System.Enum.GetName(GetType(ChartType), Me.chrtsMain.AreaChart.LineDrawStyle), 0))

******************************************************************************************

Replies
Michael Reese
Michael Reese
Advanced StrataFrame User (533 reputation)Advanced StrataFrame User (533 reputation)Advanced StrataFrame User (533 reputation)Advanced StrataFrame User (533 reputation)Advanced StrataFrame User (533 reputation)Advanced StrataFrame User (533 reputation)Advanced StrataFrame User (533 reputation)Advanced StrataFrame User (533 reputation)Advanced StrataFrame User (533 reputation)
Group: StrataFrame Users
Posts: 235, Visits: 1.6K
The Combobox will load the Enumeration fine. However, It will not load the value from my BO.Chartype column. When I select an item, the BO is not updated?

I set the SFCombo to the following; 

1. Set BindingField to MyChartypeField

2. Set the BO to MyBoChartsInventory1

3. Set the Populationtype to Enumeration

4. Set Populate EnunName to MyEnumChartype

5. PopulationOnFormLoad to FormLoad

What am I missing?

StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
When binding a combo box to an enumeration, you have to have the bound field typed as that enumeration.  Meaning that if you have enum MyEnum, then the field on your BO should be customized so that it returns a MyEnum.  Then, the binding will work correctly.  So, if the column in the database is an integer type it will cast directly to the enum type, but if you want to store the data in a string column, you'll need to use custom code and put something like this:

Public Property MyField As MyEnum
    Get
        Return CType(Enum.Parse(GetType(MyEnum), CType(Me.CurrentRow("MyField"), String)), MyEnum)
    End Get
    Set(ByVal value As MyEnum)
        Me.CurrentRow("MyField") = value.ToString()
    End Set
End Property

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