﻿<?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 » Business Objects and Data Access (How do I?)  » How to populate comboboxes with options such as M/F for Male/Female (longer lists of course)</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Tue, 09 Jun 2026 02:20:15 GMT</lastBuildDate><ttl>20</ttl><item><title>How to populate comboboxes with options such as M/F for Male/Female (longer lists of course)</title><link>http://forum.strataframe.net/FindPost11827.aspx</link><description>In .NET it is usual (recommended?) to use integers and ennumerations to identify options.&amp;nbsp; Nevertheless, I still like to use single letters such as M/F for Male/Female etc and I can get away with it since I don't deal in multilingual apps.&lt;/P&gt;&lt;P&gt;The question is, what is the best way to I populate comboxes using Strataframe in those cases?&lt;/P&gt;&lt;P&gt;TIA,&lt;/P&gt;&lt;P&gt;Alex</description><pubDate>Thu, 04 Oct 2007 10:01:39 GMT</pubDate><dc:creator>AlexSosa</dc:creator></item><item><title>RE: How to populate comboboxes with options such as M/F for Male/Female (longer lists of course)</title><link>http://forum.strataframe.net/FindPost11843.aspx</link><description>Alex,&lt;/P&gt;&lt;P&gt;[quote]The question is, what is the best way to I populate comboxes using Strataframe in those cases?[/quote]&lt;/P&gt;&lt;P&gt;You can use any data type you need as it relates to binding.&amp;nbsp; In this example you may not want to use an enum, as these will always be stored as an integer.&amp;nbsp; You will want to create your data source manually:&lt;/P&gt;&lt;P&gt;[codesnippet]Dim myTable As New DataTable("")&lt;BR&gt;Dim newRow As DataRow&lt;/P&gt;&lt;P&gt;'-- Create the columns&lt;BR&gt;myTable.Columns.Add("display",GetType(String))&lt;BR&gt;myTable.Columns.Add("value", GetType(String))&lt;/P&gt;&lt;P&gt;'-- Then populate your table&lt;BR&gt;newRow = MyTable.NewRow()&lt;BR&gt;newRow.Items("display") = "Apple"&lt;BR&gt;newRow.Items("value") = "A"&lt;BR&gt;MyTable.Rows.Add(newRow)&lt;/P&gt;&lt;P&gt;'-- Once populated, set the combo&lt;BR&gt;MyCombo.DisplayMember = "display"&lt;BR&gt;MyCombo.ValueMember = "value"&lt;BR&gt;MyCombo.DataSource = MyTable[/codesnippet]&lt;/P&gt;&lt;P&gt;You will bind to the combo just as you would for an enum, the difference is that the SelectedValue or value member of the combo will bind to the [value] field in the table which you have defined as a string, which in return will allow you to bind to a character field, which ultimately gets saved back to the database as character.&amp;nbsp; Hope this helps. :)</description><pubDate>Thu, 04 Oct 2007 10:01:39 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: How to populate comboboxes with options such as M/F for Male/Female (longer lists of course)</title><link>http://forum.strataframe.net/FindPost11839.aspx</link><description>Thank you Peter.&lt;/P&gt;&lt;P&gt;Alex</description><pubDate>Thu, 04 Oct 2007 09:06:49 GMT</pubDate><dc:creator>AlexSosa</dc:creator></item><item><title>RE: How to populate comboboxes with options such as M/F for Male/Female (longer lists of course)</title><link>http://forum.strataframe.net/FindPost11838.aspx</link><description>Hi Alex,&lt;/P&gt;&lt;P&gt;We store the enum (integer) value so the above wouldn't work for you.&lt;/P&gt;&lt;P&gt;I've never had to do the same with an option group so I can't help with that one.&lt;/P&gt;&lt;P&gt;Cheers, Peter</description><pubDate>Wed, 03 Oct 2007 23:18:33 GMT</pubDate><dc:creator>Peter Jones</dc:creator></item><item><title>RE: How to populate comboboxes with options such as M/F for Male/Female (longer lists of course)</title><link>http://forum.strataframe.net/FindPost11837.aspx</link><description>Thank you Peter,&lt;/P&gt;&lt;P&gt;I am still a newbie so I can' t tell from reading your code&amp;nbsp;if&amp;nbsp;your technique stores a&amp;nbsp;number or a character in the table?&amp;nbsp; I'd like to store a character in the table.&lt;/P&gt;&lt;P&gt;Similar problem with optionbuttons.&amp;nbsp; How do you handle&amp;nbsp;that one?&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Alex</description><pubDate>Wed, 03 Oct 2007 20:22:21 GMT</pubDate><dc:creator>AlexSosa</dc:creator></item><item><title>RE: How to populate comboboxes with options such as M/F for Male/Female (longer lists of course)</title><link>http://forum.strataframe.net/FindPost11836.aspx</link><description>You might also use an attribute on each enum value to indicate an alternate value to use. See this post:&lt;br&gt;
&lt;br&gt;
[url]http://forum.strataframe.net/FindPost5781.aspx[/url]</description><pubDate>Wed, 03 Oct 2007 17:45:26 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: How to populate comboboxes with options such as M/F for Male/Female (longer lists of course)</title><link>http://forum.strataframe.net/FindPost11834.aspx</link><description>Hi ALex,&lt;/P&gt;&lt;P&gt;You can still use an enum but show a single letter (or a full name) to the user. Our enum BO's just have the following code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Private Sub boenBatchTypes_ParentFormLoading() Handles Me.ParentFormLoading&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim ColDesc As String = "Description"&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim dt As New Data.DataTable&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dt = MicroFour.StrataFrame.Tools.Common.BuildDataTableFromEnum(GetType(UtilEnums.clsEnum.BatchTypes))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ' Localise Batch names&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; For i As Integer = 0 To dt.Rows.Count - 1&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dt.Rows.Item(i).Item(ColDesc) = UtilLocalisation.clsLocalise.Localise(dt.Rows.Item(i).Item(ColDesc).ToString)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Next&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dt.DefaultView.Sort = ColDesc&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Me.CopyDataFrom(dt.DefaultView.ToTable, MicroFour.StrataFrame.Business.BusinessCloneDataType.ClearAndFillFromCompleteTable)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dt = Nothing&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End Sub&lt;/P&gt;&lt;P&gt;In this example:&lt;/P&gt;&lt;P&gt;.BuildDataTableFromEnum - standard SF function to extract our "batch name" enums and creates a data table&lt;/P&gt;&lt;P&gt;UtilLocalisation.. - is our own function to localise the enum description.&lt;/P&gt;&lt;P&gt;Me.CopyDataFrom - standard SF sub to load the populate the BO.&lt;/P&gt;&lt;P&gt;Easy as and works a treat.&lt;/P&gt;&lt;P&gt;&lt;BR&gt;Cheers, Peter</description><pubDate>Wed, 03 Oct 2007 16:19:00 GMT</pubDate><dc:creator>Peter Jones</dc:creator></item></channel></rss>