Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1705
How can I set the format of a column at runtime?
posted

I don't set up any columns at design time; this happens automatically when I get my data and do a SetDataBinding().  When some of these columns contain date info, how do I set the format?  I tried setting the format by saying grid.DisplayLayout.Bands[0].Columns[columnName].Format = "d " right after the SetDataBinding, but it didn't change the look of that column.  Should I be doing this in an event of some sort?

Parents
  • 1800
    posted

    You have to set the column style in Initialize layout event of the grid. As soon SetDataBinding is called, the InitializeLayout event will be fired. So set the column style to Date in InitializeLayout event.

    If you need a specific format, the best way is to format the data in source. If you have an stored procedure (SP) to load the data, bring in the format in SP and bind it. If not you can specify the format in initializelayout as

    Example: For a column type as double,

    grid.DisplayLayout.band(0).Columns("YourColumnName").format = "##0.00"

Reply Children
No Data