Skip to main content
Added question specific explanation also.
Source Link
Nikhil Girraj
  • 1.1k
  • 1
  • 15
  • 34

Its simple,

myDataGridView.Rows.Add(value1, value2, value3...);

It worked when I had configured my DGV previously for the coming data columns through the GUI. So in your case, it would be like:

private void LoadStudentGrades(int gradeParaleloId, int subjectId)
{
    GradeStudentRepository gradeStudentRepo = new GradeStudentRepository();
    students = gradeStudentRepo.FindAllGradeStudents().Where(g => g.GradeParaleloId == gradeParaleloId).Select(g => g.Student);

    int i = 1;
    foreach (var student in students)
    {
        dataGridView1.Rows.Add(i.ToString(), student.LastNameFather + " " + student.LastNameMother + ", " + student.Name);
        i++;
    }
}

May be you have to configure the DGV for the columns and their names separately.

Its simple,

myDataGridView.Rows.Add(value1, value2, value3...);

It worked when I had configured my DGV previously for the coming data columns through the GUI.

Its simple,

myDataGridView.Rows.Add(value1, value2, value3...);

It worked when I had configured my DGV previously for the coming data columns through the GUI. So in your case, it would be like:

private void LoadStudentGrades(int gradeParaleloId, int subjectId)
{
    GradeStudentRepository gradeStudentRepo = new GradeStudentRepository();
    students = gradeStudentRepo.FindAllGradeStudents().Where(g => g.GradeParaleloId == gradeParaleloId).Select(g => g.Student);

    int i = 1;
    foreach (var student in students)
    {
        dataGridView1.Rows.Add(i.ToString(), student.LastNameFather + " " + student.LastNameMother + ", " + student.Name);
        i++;
    }
}

May be you have to configure the DGV for the columns and their names separately.

Source Link
Nikhil Girraj
  • 1.1k
  • 1
  • 15
  • 34

Its simple,

myDataGridView.Rows.Add(value1, value2, value3...);

It worked when I had configured my DGV previously for the coming data columns through the GUI.