RadGridView issues with dynamic headers/data

2 posts, 0 answers
  1. Vivian
    Vivian avatar
    1 posts
    Member since:
    Jan 2015

    Posted 02 Jan 2015 Link to this post

    Hi Guys, 

    Sorry about bringing up a probably n00b question. 
    I have a string which is in the format of a csv. I have parsed the csv and want to show the contents in a RadGridView. 
    This is what I have done and a bit lost at the moment.

    //COnstructor accepting string
            public ucCsvEditor(string csv)
                using (StringReader sr = new StringReader(csv))
                    var reader = new CsvReader(sr);
                    //CSVReader will now read the whole file into an enumerable
                    while (reader.Read())
                        string[] records = reader.CurrentRecord;
                        string[] headers = reader.FieldHeaders;
                    //ObservableCollection<string[]> myCollection = new ObservableCollection<string[]>(variablesValue);
                    radGridView.ItemsSource = variablesValue;

           <telerik:RadGridView x:Name="radGridView" Grid.Row="0" AutoGenerateColumns="True" IsReadOnly="False" CanUserDeleteRows="False" />

    I call this GridView from the following code:
    if (!string.IsNullOrEmpty(csvData))
                    RadWindow winCsvEditor = new RadWindow();
                    ucCsvEditor temp = new ucCsvEditor(csvData);
                    winCsvEditor.Content = temp;
                    winCsvEditor.Header = "CSV Editor";
                    winCsvEditor.Owner = this;
                    winCsvEditor.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner;
                    winCsvEditor.CanClose = true;
                    MessageBox.Show("No Variables available to edit");

    The output is shown as shown int he attachment. 

    Not exactly the output I was looking for. 
    Since the string[] keeps changing each time I call the GridView depending on the parameters. How do I dynamically build the RadGridView. ?? Any helps is appreciated. 
  2. Dimitrina
    Dimitrina avatar
    3769 posts

    Posted 05 Jan 2015 Link to this post


    Does the same approach work fine when populating a DataGrid or a ListBox. You can also check the Loading Data from XML article on how to populate RadGridView. 


    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