Format AutoGenerated Columns

2 posts, 0 answers
  1. Javid
    Javid avatar
    2 posts
    Member since:
    Oct 2011

    Posted 09 Jan 2012 Link to this post


    I'm using RadGridView.I need to format the cells of grid like "###,###".Moreover as long as my ItemSource is totally arbitrary, I can not define the columns in xaml or code. However, I know the first column is of string type and the rest are double
    I need something like :

    public void radGridView1_Loading(e) // or formatting
                e.Cell.Format = "###,###";

    Thanks in advance
  2. StevenDale
    StevenDale avatar
    100 posts
    Member since:
    Apr 2007

    Posted 12 Apr 2012 Link to this post

    I know this is a late response but others may be looking for the same thing.

    You should be able to do the following in RowLoaded event of your RadGridView. This is what I do when I am binding dynamically using a datatable to format my columns. This example formats my date column.

    if (e.Row.DataContext is DataRow)
    for (int i = 0; i < (e.Row.DataContext as DataRow).ItemArray.Count(); i++)
    if ((e.Row.DataContext as DataRow).ItemArray[i] is DateTime)
    if (string.IsNullOrWhiteSpace(e.Row.Cells[i].DataColumn.DataFormatString))
    e.Row.Cells[i].DataColumn.DataFormatString = "MM/dd/yyyy HH:mm";

  3. DevCraft R3 2016 release webinar banner
Back to Top