radgridview dynamic gridviewcolumn formatting

3 posts, 0 answers
  1. Loic
    Loic avatar
    7 posts
    Member since:
    May 2014

    Posted 10 Nov 2014 Link to this post


    I create dynamically my columns through an attached property and can't seem to set the string format for my columns. I would like my number have the format 1234.00 > 1,234.00

    How to do that ?

    I tried with:
    in my .xaml:

    <telerik:RadGridView  x:Name="RadGridView1"    
                                  ItemsSource="{Binding ResultsViewModelList}" AutoGenerateColumns="False"  
                                  custom:GridViewDataColumnsBehavior.BindableColumns="{Binding ColumnCollection}"
    in my view model :
     // Toggle Column
    GridViewToggleRowDetailsColumn gridRowToggle = new GridViewToggleRowDetailsColumn();

    //data column
    GridViewDataColumn column =
    new GridViewDataColumn();
     string columnName = "column1";
     column.Header = columnName;
     column.UniqueName = columnName;
     column.DataMemberBinding = new Binding("ResultDataDictionary[" + columnName + "]");
     column.DataMemberBinding.StringFormat = "0:N"//also tried with N , {0:N}, ...
    //also tried > column.DataFormatString = "0:N";
     column.DataType = typeof(double);

    in GridViewDataColumnsBehavior:

    public static readonly DependencyProperty BindableColumnsProperty =
                                                    new UIPropertyMetadata(null, BindableColumnsPropertyChanged));
            private static void BindableColumnsPropertyChanged(DependencyObject source, DependencyPropertyChangedEventArgs e)
                RadGridView RadGridView = source as RadGridView;
                ObservableCollection<GridViewColumn> columns = e.NewValue as ObservableCollection<GridViewColumn>;
                if (columns == null)
                foreach (GridViewColumn column in columns)

  2. Loic
    Loic avatar
    7 posts
    Member since:
    May 2014

    Posted 10 Nov 2014 Link to this post

    How to delete the thread?
    I just find out that the data that I passed is a string and not a number. That is why the formatting does not work.
  3. Dimitrina
    Dimitrina avatar
    3769 posts

    Posted 10 Nov 2014 Link to this post


    I am glad to hear you managed to resolve the issue. I would suggest you leaving this thread as it could also be useful to the community.


    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Back to Top