﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » StrataFrame Application Framework - V1 » WinForms (How do I?)  » Combobox</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Tue, 29 Sep 2026 02:10:46 GMT</lastBuildDate><ttl>20</ttl><item><title>Combobox</title><link>http://forum.strataframe.net/FindPost11964.aspx</link><description>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&amp;nbsp;get the&amp;nbsp;error above.&amp;nbsp;The column is not null and I have taken care of that in the BOMapper.&lt;/P&gt;&lt;P&gt;My combobox is bindingfield is configure to the ChartType column and businessobject is the BOChartsInventory1. &lt;/P&gt;&lt;P&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;********************************************************************************&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color=#0000ff size=2&gt;&lt;FONT color=#0000ff size=2&gt;Dim&lt;/FONT&gt;&lt;FONT size=2&gt; chartTypes &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;String&lt;/FONT&gt;&lt;FONT size=2&gt;() = System.Enum.GetNames(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;GetType&lt;/FONT&gt;&lt;FONT size=2&gt;(ChartType))&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Dim&lt;/FONT&gt;&lt;FONT size=2&gt; ct &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;As&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;String&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;For&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Each&lt;/FONT&gt;&lt;FONT size=2&gt; ct &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;In&lt;/FONT&gt;&lt;FONT size=2&gt; chartTypes&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Me&lt;/FONT&gt;&lt;FONT size=2&gt;.cboChartype.Items.Add(ct)&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Next&lt;/FONT&gt;&lt;FONT size=2&gt; ct&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Me&lt;/FONT&gt;&lt;FONT size=2&gt;.cboChartype.SelectedValue = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Me&lt;/FONT&gt;&lt;FONT size=2&gt;.cboChartype.Items(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Me&lt;/FONT&gt;&lt;FONT size=2&gt;.cboChartype.FindString(System.Enum.GetName(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;GetType&lt;/FONT&gt;&lt;FONT size=2&gt;(ChartType), &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Me&lt;/FONT&gt;&lt;FONT size=2&gt;.chrtsMain.AreaChart.LineDrawStyle), 0))&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;P&gt;******************************************************************************************</description><pubDate>Tue, 16 Oct 2007 09:08:19 GMT</pubDate><dc:creator>Michael Reese</dc:creator></item><item><title>RE: Combobox</title><link>http://forum.strataframe.net/FindPost12018.aspx</link><description>When binding a combo box to an enumeration, you have to have the bound field typed as that enumeration.&amp;nbsp; Meaning that if you have enum MyEnum, then the field on your BO should be customized so that it returns a MyEnum.&amp;nbsp; Then, the binding will work correctly.&amp;nbsp; 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:&lt;/P&gt;&lt;P&gt;Public Property MyField As MyEnum&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Get&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Return CType(Enum.Parse(GetType(MyEnum), CType(Me.CurrentRow("MyField"), String)), MyEnum)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End Get&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set(ByVal value As MyEnum)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Me.CurrentRow("MyField") = value.ToString()&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End Set&lt;BR&gt;End Property</description><pubDate>Tue, 16 Oct 2007 09:08:19 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: Combobox</title><link>http://forum.strataframe.net/FindPost12013.aspx</link><description>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?&lt;/P&gt;&lt;P&gt;I set the SFCombo to the following;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Set BindingField to MyChartypeField&lt;/P&gt;&lt;P&gt;2. Set the BO to MyBoChartsInventory1&lt;/P&gt;&lt;P&gt;3.&amp;nbsp;Set the Populationtype to Enumeration &lt;/P&gt;&lt;P&gt;4. Set Populate EnunName to MyEnumChartype&lt;/P&gt;&lt;P&gt;5. PopulationOnFormLoad to FormLoad&lt;/P&gt;&lt;P&gt;What am I missing?</description><pubDate>Tue, 16 Oct 2007 02:13:02 GMT</pubDate><dc:creator>Michael Reese</dc:creator></item><item><title>RE: Combobox</title><link>http://forum.strataframe.net/FindPost11997.aspx</link><description>Thanks &lt;/P&gt;&lt;P&gt;I put the error in the post subject line.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN id=ctl02_ctlViewTopics_ctlPanelBar_ctlForumTopics_ctl26_ctlEditableDescription&gt;&lt;SPAN id=ctl02_ctlViewTopics_ctlPanelBar_ctlForumTopics_ctl26_ctlEditableDescription_lblDescription&gt;&lt;FONT class=SmallGrayText&gt;"Conversion from type 'DBNull' to type 'String' is not valid."&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;</description><pubDate>Mon, 15 Oct 2007 12:12:41 GMT</pubDate><dc:creator>Michael Reese</dc:creator></item><item><title>RE: Combobox</title><link>http://forum.strataframe.net/FindPost11982.aspx</link><description>I don't see the error anywhere in the post, so I'm going to assume that it's an InvalidCastException?&amp;nbsp; 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.&amp;nbsp; 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).&amp;nbsp; 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.&amp;nbsp; That method also takes advantage of the &amp;lt;EnumDisplayValueAttribute&amp;gt; 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).</description><pubDate>Mon, 15 Oct 2007 09:50:40 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: Combobox</title><link>http://forum.strataframe.net/FindPost11968.aspx</link><description>Hi Michael,&lt;/P&gt;&lt;P&gt;I would be having a look in the CurrentDataTable view when your code breaks on the&amp;nbsp;error. I would imagine that you will, indeed, find a row with a null where you are not expecting a null to appear.&lt;/P&gt;&lt;P&gt;Cheers, Peter</description><pubDate>Sun, 14 Oct 2007 18:07:06 GMT</pubDate><dc:creator>Peter Jones</dc:creator></item></channel></rss>