0
클래스 학생에게 DataGridView에 또 다른 클래스에서어떻게 형태로
class StudentInfo
{
public int StudentId { get; set; }
public String FullName { get; set; }
public String LessonStudy { get; set; }
public String GroupName { get; set; }
public StatusStudentBell StatusStudentBell { get; set; }
}
클래스 StatusStudentBell
class StatusStudentBell
{
public String Bell1 { get; set; }
public String Bell2 { get; set; }
public String Bell3 { get; set; }
public String Bell4 { get; set; }
}
을 클래스 목록을 연결하는
ConservatoryEntities ConservatoryEntities = new ConservatoryEntities();
private void Form1_Load(object sender, EventArgs e)
{
var student = ConservatoryEntities.LocationTimeClasses.Where(l =>
l.Day.Name.Equals("Friday"));
var dateNow = DateTime.Parse(DateTime.UtcNow.ToShortDateString());
var studentInfo = new List<StudentInfo>();
foreach (var item in student)
{
studentInfo.AddRange(item.LessonToFieldStudy.FieldOfStudy.Students.ToList().Select(s =>
new StudentInfo()
{
FullName = s.Name,
GroupName = s.Team.Name,
LessonStudy = s.FieldOfStudy.Name,
StatusStudentBell = new StatusStudentBell()
{
Bell1 = item.LessonToFieldStudy.RollCalls.FirstOrDefault(r => r.fk_bell_Id == 1 &&
r.Date == dateNow)?.Absent + "",
Bell2 = item.LessonToFieldStudy.RollCalls.FirstOrDefault(r => r.fk_bell_Id == 2 &&
r.Date == dateNow)?.Absent + "",
}
}).ToList());
}
}
저는 C#을 사용하고 있으며 초보자입니다.
C#에서는 내가 만든이 목록을 dataGridView에 연결하려고합니다.
StatusStudentBell
클래스가 DataGridView에 연결할 수있는 StudentInfo
목록을 어떻게 추가 할 수 있습니까?
도와주세요.
다음
확인 : https://stackoverflow.com/questions/6473326/using-a-list-as-a-data-source-for-datagridview 또한 조회하려고 조금 더. – JCM