Main Menu
Knowledge Base
Product Registration
Log an Incident
Request a Feature
Search Incidents/Bug Reports

Search KB

Please note: In an effort to better serve you, we are in the process of restructuring DevCenter. In the process, we have moved many items that you may be used to finding in DevCenter over to the Main Site. If you are having trouble locating something, please try looking at the following places:

Knowledge Base Article: KB01746

HOWTO:UltraWinGrid Cell Formatting Using Format

The information in this article applies to:
UltraWinGrid (v1.0.5005)
  Article Created: 

Last Updated:

Article Type
How To
Page Options
Average Rating:
2 out of 10

Rate this page
Print this page
E-mail this page
Add to Favorites


User input into cells containing currency and dates need to be formatted for display and follow localization guidelines so that currency and dates display differently in different localities.

Additional Information

How do I display my currency values with a "$" sign?
How do I display currency so it will conform to the Windows locale settings?
How do I display a date/time field with just the month, day, and year?
How do I display the month, day and year so it will conform to the Windows locale settings?

The solution to all of the above issues is to use the .Format property of the column object.

Step-By-Step Example

This sample project displays three columns. The CurrencyValue column uses a fixed format of "$#,##0.00" to display the currency with a "$" sign, the DateValue1 column uses the "localized" short date standard format, and DateValue2 displays the time portion of a date field in "hh:mm:ss" format:

This project consists of the following files:
clsDataTable.vb - exposes the clsDataTable class which exposes the MakeDataTable method used to create the sample DataTable. This code is not reviewed.
Form1.vb - contains the code relevant to this project and consists of the following code regions:
Form Events
The Form Events Region consists of the following event handlers:
The Form Load event creates an instance of the clsDataTable object, calls the MakeDataTable method and binds the result to the UltraWinGrid DataSource:

' create DataTable and Bind to Grid
Dim sampleDataMaker As New clsDataTable()
UltraGrid1.DataSource = sampleDataMaker.MakeDataTable

UltraWinGrid Events The UltraWinGrid Events Region consists of the following event handlers:
The code in the UltraWinGrid InitializeLayout event tells the grid to fit the columns to the width of the grid and format the three columns as indicated:

e.Layout.AutoFitColumns = True

e.Layout.Bands(0).Columns("CurrencyValue").Format = "$#,##0.00"

e.Layout.Bands(0).Columns("DateValue1").Format = "d"

e.Layout.Bands(0).Columns("DateValue2").Format = "hh:mm:ss"

This sample project demonstrates the simplest method of formatting columns using the .Format property of the Column object. Review the Microsoft documentation regarding the "Format Function" for more information regarding the capabilities of the .Format property.

 UltraWinGrid Cell Formatting Using Format Property

How would you rate the quality of this content?
Poor -----------------------------------------> Outstanding

Tell us why you rated the content this way. (optional)