我看你代码也没有写完,我给你修改好了,你的另一个帖子,也是这样的思路就行,将这个编辑器作为flexgrid 的列编辑器即可
- public partial class Form1 : Form
- {
- List<Student> Students = new List<Student>();
- public Form1()
- {
- InitializeComponent();
- List<Class> Classes = new List<Class>();
- Classes.Add(new Class { ClassCode = "101", ClassName = "一(1)班" });
- Classes.Add(new Class { ClassCode = "102", ClassName = "一(2)班" });
-
- Students.Add(new Student { StudentName = "赵一", Gender = "男", ClassCode = "101" });
- Students.Add(new Student { StudentName = "钱二", Gender = "女", ClassCode = "101" });
- Students.Add(new Student { StudentName = "孙三", Gender = "男", ClassCode = "102" });
- Students.Add(new Student { StudentName = "李四", Gender = "女", ClassCode = "102" });
- cmbClass.ItemsDataSource = Classes;
- cmbClass.ItemsDisplayMember = "ClassName";
- cmbClass.ItemsValueMember = "ClassCode";
- cmbStudents.ItemsDataSource = Students;
- cmbStudents.ItemsDisplayMember = "StudentName";
- cmbStudents.ItemsValueMember = "StudentName";
- cmbStudents.BeforeDropDownOpen += CmbStudents_BeforeDropDownOpen;
- //1.想实现选择班级的时候,下面的只显示这个班级的学生
- //2.想从下面这个控件中取出所有字段的值,即StudentName Gender ClassCode
- }
- private void CmbStudents_BeforeDropDownOpen(object sender, CancelEventArgs e)
- {
- cmbStudents.ItemsDataSource = Students.Where(t => t.ClassCode ==cmbClass.Value.ToString());
- }
- }
复制代码 |