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:
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.
QuestionsHow 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? SolutionsThe solution to all of the above issues is to use the .Format property of the column object.
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 EventsThe Form Events Region consists of the following event handlers:MyBase.LoadThe Form Load event creates an instance of the clsDataTable object, calls the MakeDataTable method and binds the result to the UltraWinGrid DataSource:
UltraWinGrid Events The UltraWinGrid Events Region consists of the following event handlers:UltraGrid1.InitializeLayoutThe 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:
ReviewThis 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.