﻿<?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?)  » Can I populate a DevExpress LookupEdit using an enum?</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Thu, 11 Jun 2026 03:17:08 GMT</lastBuildDate><ttl>20</ttl><item><title>Can I populate a DevExpress LookupEdit using an enum?</title><link>http://forum.strataframe.net/FindPost7299.aspx</link><description>Hi,&lt;/P&gt;&lt;P&gt;I would like to use enums to populate a LookupEdit column in a DevExpress grid. I've worked my way to the BuildDataTableFromEnum method and that seemed to hold the clue but I can't work out how to use it. Before spending a lot of time on this I thought I had better ask if it is even possible. If it is, do you have a code snippet I could use?&lt;/P&gt;&lt;P&gt;Cheers, Peter</description><pubDate>Tue, 13 Mar 2007 22:52:20 GMT</pubDate><dc:creator>Peter Jones</dc:creator></item><item><title>RE: Can I populate a DevExpress LookupEdit using an enum?</title><link>http://forum.strataframe.net/FindPost7459.aspx</link><description>Hi,&lt;/P&gt;&lt;P&gt;&lt;BR&gt;For anyone who is interested the following seems to work ok when binding a DevExpress lookup edit to an internal enum. It involves creating a BO for each enum which, of course, gives great portability.&lt;/P&gt;&lt;P&gt;&lt;BR&gt;1. Make a generic view to use when creating an enum BO:&lt;/P&gt;&lt;P&gt;SELECT '' AS Description, '' AS Value&lt;/P&gt;&lt;P&gt;&lt;BR&gt;2. Created BO using the above view. In this example we are creating a BO for our DeviceType enums.&lt;/P&gt;&lt;P&gt;&lt;BR&gt;3. Created Business Binding Source mapped to the BO.&lt;/P&gt;&lt;P&gt;&lt;BR&gt;4. Add this code to the enum's BO's ParentFormLoading event:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Private Sub boEnumDeviceType_ParentFormLoading() Handles Me.ParentFormLoading&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim dt As New Data.DataTable&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dt = MicroFour.StrataFrame.Tools.Common.BuildDataTableFromEnum(GetType(TMS_Test_01.TMSEnums.DeviceType))&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Me.CopyDataFrom(dt, MicroFour.StrataFrame.Business.BusinessCloneDataType.ClearAndFillFromCompleteTable)&lt;BR&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;5. Created a LookUpEdit control in DevExpress using the BBS as the datasource and mapped Description as the display member and Value as the value member.&lt;/P&gt;&lt;P&gt;&lt;BR&gt;And that was it. The combo box shows the enum descriptions and the value saved to the database is enum's integer value.&lt;/P&gt;&lt;P&gt;So, all we need to do is create BO's for each of our enums that are visible on the UI and use them just as we would a table.&lt;/P&gt;&lt;P&gt;Cheers, Peter</description><pubDate>Tue, 13 Mar 2007 22:52:20 GMT</pubDate><dc:creator>Peter Jones</dc:creator></item><item><title>RE: Can I populate a DevExpress LookupEdit using an enum?</title><link>http://forum.strataframe.net/FindPost7455.aspx</link><description>I don't think we have one that will just get the integer value for the enum.&amp;nbsp; We originally had all of the method return a DataTable with the value column populated with an integer, but we discovered that you couldn't bind to a strong-typed property that had been typed as an enum, but you can bind an enum populated combo box to an integer-typed property, so we changed the methods to populate the value column with the actual enum value.&amp;nbsp; This all happened in version 1.1 or 1.2, I'm not sure.&amp;nbsp; &lt;/P&gt;&lt;P&gt;If you want to be able to populate a column with the integer value, you can use the CreateDataTableFromEnum method and add an extra column, say "ValueInt", to the table, cycle through the rows, and set the integer value.&amp;nbsp; Then you'll just have to change the ValueMember of the control to "ValueInt", not "value".</description><pubDate>Tue, 13 Mar 2007 16:16:20 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: Can I populate a DevExpress LookupEdit using an enum?</title><link>http://forum.strataframe.net/FindPost7454.aspx</link><description>Hi,&lt;/P&gt;&lt;P&gt;Ok then. When I first looked at this issue that was the only method I could identify that could create an 'enum table'. Does SF have another method that will return the enum integer in the value column?&lt;/P&gt;&lt;P&gt;Cheers, Peter</description><pubDate>Tue, 13 Mar 2007 15:55:31 GMT</pubDate><dc:creator>Peter Jones</dc:creator></item><item><title>RE: Can I populate a DevExpress LookupEdit using an enum?</title><link>http://forum.strataframe.net/FindPost7437.aspx</link><description>When you create a DataTable from that tools method, the Value column of the DataTable will contain the actual enumeration value, not the integer tied to the enum value.</description><pubDate>Tue, 13 Mar 2007 08:44:23 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: Can I populate a DevExpress LookupEdit using an enum?</title><link>http://forum.strataframe.net/FindPost7432.aspx</link><description>Hi,&lt;/P&gt;&lt;P&gt;Finally got around to doing this. I can create a data table ok and it has two columns headed Description and Value. The problem is that each column contains the enumation description (Dev0, Dev1 etc) but&amp;nbsp;no enumeration value (0,1,3 etc).&lt;/P&gt;&lt;P&gt;My code the create the tables is:&lt;/P&gt;&lt;FONT size=2&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Dim&lt;/FONT&gt;&lt;FONT size=2&gt; dt &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;New&lt;/FONT&gt;&lt;FONT size=2&gt; Data.DataTable&lt;/P&gt;&lt;P&gt;dt = MicroFour.StrataFrame.Tools.Common.BuildDataTableFromEnum(&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;GetType&lt;/FONT&gt;&lt;FONT size=2&gt;(TMS_Test_01.TMSEnums.DeviceType))&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size=2&gt;My code to create the enumeration is:&lt;/FONT&gt;&lt;/P&gt;&lt;FONT size=2&gt;&lt;FONT size=2&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Public&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Enum&lt;/FONT&gt;&lt;FONT size=2&gt; DeviceType &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;Integer&lt;/P&gt;&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;P&gt;Dev0 = 0&lt;/P&gt;&lt;P&gt;Dev1 = 1&lt;/P&gt;&lt;P&gt;Dev2 = 2&lt;/P&gt;&lt;P&gt;Dev3 = 3&lt;/P&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;End&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;Enum&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color=#0000ff size=2&gt;What elso do I need to do?&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color=#0000ff size=2&gt;Cheers, Peter&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color=#0000ff size=2&gt;&amp;nbsp;&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;</description><pubDate>Tue, 13 Mar 2007 00:10:35 GMT</pubDate><dc:creator>Peter Jones</dc:creator></item><item><title>RE: Can I populate a DevExpress LookupEdit using an enum?</title><link>http://forum.strataframe.net/FindPost7300.aspx</link><description>This will require the use of an embedded control which we do not have a wrapper for.&amp;nbsp; However, you can use the BuildDataTableFromEnum static (shared) method in the MicroFour.StrataFrame.Tools.Common namespace to create the data table that can then be used as a data source within the LookupEdit control.&amp;nbsp; For us to provide the native SF Enum population within the embedded control would require use to re-write some of the DevExpress type editors which just is not feasible.&amp;nbsp; The good news is that you can at least get the final result you are looking for. :)</description><pubDate>Sun, 04 Mar 2007 23:17:14 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item></channel></rss>