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))

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

Reply
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
I don't see the error anywhere in the post, so I'm going to assume that it's an InvalidCastException?  Well, most likely, the field you're binding to is an enum field, and the combo box is populated with strings, so that's not going to work.  Your best bet would be to use the PopulationType = Enumeration / PopulationEnumName = "enum name" on the combo box (they can be set through the property sheet).  If you have to populate it programmatically, then you'll want to use the MicroFour.StrataFrame.Tools.Common.BuildDataTableFromEnum() method and pass over the combo box you want to populate.  That method also takes advantage of the <EnumDisplayValueAttribute> that you can apply to the items in your enum (populates the combo box with what you place in the attribute, rather than the name of the enum value; easier on your users).
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