0
我需要使用for循环将'datagridview'访问数据库中的单个列添加到'listbox'。到目前为止,我没有返回任何错误,但没有检索任何数据。C# - 使用for循环将Datagridview列添加到列表框中
private void frmProject6_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'enrollmentsDataSet.Enrollments' table. You can move, or remove it, as needed.
this.enrollmentsTableAdapter.Fill(this.enrollmentsDataSet.Enrollments);
}
private void lstUniqueInstructor_SelectedIndexChanged(object sender, EventArgs e)
{
this.lstUniqueInstructor.Items.Clear();
for(int i = 0; i < this.dgvEnrollments.Rows.Count; i++)
{
this.lstUniqueInstructor.Items.Add(this.dgvEnrollments.Columns[4].HeaderText);
}
}