estoy tratando de ejecutar este código, y me sale una excepción:¿Cómo puedo agregar datos manualmente a un dataGridView?
índice estaba fuera del rango. Debe ser no negativo y menor que el tamaño de la colección. Nombre de parámetro: índice de
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)
{
DataGridViewRow row = new DataGridViewRow();
row.Cells[0].Value = i.ToString();
row.Cells[1].Value = student.LastNameFather + " " + student.LastNameMother + ", " + student.Name;
dataGridView1.Rows.Add(row);
i++;
}
}
que crear manualmente las columnas en el DataGridView, y ahora me gustaría para rellenar los campos que utilizan este pequeño método.
¿Estás seguro de que hay columnas disponibles para 'datagridview1'? – V4Vendetta
¿Qué quieres decir con "¿Creé manualmente las columnas en la vista de cuadrícula de datos"? ¿Quiere decir que definió columnas en la hoja de propiedades "Columnas" de la instancia de DataGridView colocada en un formulario, o quiere decir que definió columnas utilizando el código C# en otro lugar? – barrypicker