StrataFrame Forum

Grid column formatting

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

By Andria Jensen - 7/3/2006

I am using the Inherited UI controls, particularly the Enhanced List.  Is there a  way to format a boolean to show up in the column as Yes/No instead of True/False?  Also, I am having trouble formatting a date column.  I want it to be 07/03/2006, but instead it is showing up as 07/03/2006 12:00:00 AM.  I have DateTime selected as FormatType and 'd' as FormatString.  Should I be doing something else?
By StrataFrame Team - 7/3/2006

On the True/False options, you can configure the column to PopulateThroughEvent rather than FormattedString and set the actual value within the RowPopulating event of the EnhancedList.  So, rather than setting the display format to "{3}" (or whatever the column index is), you go to the RowPopulating event and set the value within it like so:

If CType(e.BusinessObject, MyBoType).TestValue Then
    e.Values(3).DisplayValue = "Yes"
Else
    e.Values(3).DisplayValue = "No"
End If

As for the datetime formatting issue, you're best bet is going to be to leave the column's type as a string and change the "{2}" to "{2:d}".  You can add whatever formatting specifier is necessary after the :  So, if you need to format a number with a comma in the thousand's place, it would be "{2:n3}".  You can find more information by searching for String.Format() in the Visual Studio help.  My link to the document is:

ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.en/dv_csref/html/120ba537-4448-4c62-8676-7a8fdd98f496.htm  (open up your VS help and paste that into the URL blank)
By Andria Jensen - 7/3/2006

Great, that works perfectly.  One more along those same lines...

I have an enum like the following:

Public Enum VerifyCode
  OkToApprove
  CannotApprove
  AERequired
End Enum

I want to use this enum to populate a combo, which I know how to do.  I also set the PascalCase to true, so they show up correctly.  I get "Ok To Approve" and Cannot Approve", but I want the last one to show up as "A/E Required".  Is there anyway to override the display value for only one enum value like this?


 

By StrataFrame Team - 7/3/2006

No, there isn't a way to do that for only one enum value.  The only thing you might try is to add the AERequired to the EnumItemsToOmit property and add a TopMostItem of AERequired.  Then, it will effectively remove the AERequired from the "enums" portion of the list and re-add it to the top of the list through the TopMostItem.  That's the only way I can think to do it.

You can always handle the ParentFormLoading event of the combo because that event fires directly after it has been populated with the enum.  Then, you could alter the data within the combo's DataSource property, which comes out as a DataTable with two columns, one for display, one for the value behind.  You would just need to modify the display value... However, this method gets a little nitty gritty, so don't blow your fingers off Smile