3

I have the following data structure:

public class StudentScore {
    public string ScoreValue{ get; set; }
}

public class Student {
    public string StudentName { get; set; }
    //Scores.Count will be = EndDate-StartDate
    public ObservableCollection<StudentScore> Scores { get;set; } 
}

ObservableCollection<Student> Students { get; set; }
public DateTime StartDate { get; set; } //Can be changed by user dynamically
public DateTime EndDate { get; set; } //Can be changed dynamically

What i am interested to achieve in WPF DataGrid/DevExpress GridControl is as follows: Column 1 is always fixed, which is student name and remaining columns will be only based on the number of Scores and each row should populate the student name and scores.

And each cell should have a two way binding where user can edit the score to reflect back in the actual VM property.

STudent poc image
I tried to set the AutoGenerateColumns property to true - it generates only two columns because I have only StudentName and Scores properties. So i need some thing that can generate columns from collection for each row.

1
  • 2
    Did the accepted answer really help you? Commented Jul 4, 2014 at 13:34

1 Answer 1

1

You can bind grid columns via the GridControl.ColumnsSource property.
Please review this approach detailed description in the following help article: Binding to a Collection of Columns.

Sign up to request clarification or add additional context in comments.

2 Comments

This does not exactly answer the question as asked. A combobox of dates is not the same as a varying amount of columns.
Especially that I have a property that is a list of values, which should generate into cells each, but all other properties are cells themself.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.