StrataFrame Forum

tying column value to enum in Browse Dialog

http://forum.strataframe.net/Topic10954.aspx

By Marcel Heitlager - 8/20/2007

I'm trying to tie a column value to an enumeration text value in Browse Dialog result.

Public Enum PlanTypes As Integer

Standard = 0

Interest = 1

Custom = 2

CustomInterest = 3

End Enum

My bo has a field called plan_type which contains the integer key.

What value do I change in the RowPopulating event?  

Thanks.

By Trent L. Taylor - 8/21/2007

This works the very same way as the ListView.  First, have you tried to just allow the enum to populate within it.  By default, any strong-typed column using an enum will attempt to perform a ToString which shold return the enum value without you having to do anything in the RowPopulating.  However, if you choose to go the RowPopulating route, just set the column that will house this value to PopulatedThroughEvent rather the a formatted value.  Then set the event args value when the event is raised:

With CType(e.BusinessObject, MyBOType)
   e.Columns(1).DisplayValue = .MyEnumField.ToString()
EndWith

A better way to parse the enum is to provide an attribute so you can get a more accurate display description:

Public Enum MyEnum As Integer
    <MicroFour.StrataFrame.Tools.EnumDisplayValue("Apple", False)> _
    Item1 = 0
    <MicroFour.StrataFrame.Tools.EnumDisplayValue("Orange", False)> _
    Item2 = 1
    <MicroFour.StrataFrame.Tools.EnumDisplayValue("Pear", False)> _
    Item3 = 3
End Enum

Then parse it out this way:

e.Columns(1).DisplayVaue = MicroFour.StrataFrame.Tools.Common.GetEnumDisplayValue(.MyEnumField)
By Marcel Heitlager - 8/23/2007

Thanks for the help.  What you put in the last post is actually what I wanted to do.