本文介绍了DataGridViewComboBoxColumn设置selectedIndex的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 您好,我运行时绑定数据到datagridview的组合框。但我怎么让它自动显示的第一个项目?我不能够找到DataGridViewComboBoxColumn将selectedIndex DataGridViewComboBoxColumn cbStudentCourse =(DataGridViewComboBoxColumn)dgStudentCourse.Columns [studentCourseStatus]。 cbStudentCourse.DataSource = Enum.GetValues(typeof运算(CourseStudentStatus)); cbStudentCourse.DisplayIndex = 1; - 更新---结果I看见有人在溶液中做这个3 链接结果你确定我需要这么长的代码只是第一个项目选择?????? 解决方案 A DataGridViewComboBoxColumn 没有的SelectedIndex 和的SelectedValue 属性。然而,你可以通过设置在 值 属性。的SelectedValue 的相同的行为p> 上。例如第一个索引值的成员具有值2,那么你应该设置 .value的=2来设置第一个指标选择。 例如 myDataGridViewComboBoxColumn.Value = 20; 在你的情况 myDataGridViewComboBoxColumn.Value = CourseStudentStatus.EnumToBeSelected.ToString(); 下面是关于的 DataGridViewComboBoxColumn hi i runtime bind the data into datagridview combobox. But how do i make it to auto display the first item? i do not able find the selectedindex from DataGridViewComboBoxColumn. DataGridViewComboBoxColumn cbStudentCourse = (DataGridViewComboBoxColumn)dgStudentCourse.Columns["studentCourseStatus"]; cbStudentCourse.DataSource = Enum.GetValues(typeof(CourseStudentStatus)); cbStudentCourse.DisplayIndex = 1;-- Update ---i saw someone doing this in solution 3LInkAre you sure i need such a long code to just have the first item selected?????? 解决方案 A DataGridViewComboBoxColumn has no SelectedIndex, and SelectedValue properties. However you can get the same behavior of SelectedValue by setting the Value property.For instance on first index the value member has value 2 then you should set .Value = "2" to set the first index selected.For examplemyDataGridViewComboBoxColumn.Value = "20";In your casemyDataGridViewComboBoxColumn.Value = CourseStudentStatus.EnumToBeSelected.ToString();Here is more details about DataGridViewComboBoxColumn 这篇关于DataGridViewComboBoxColumn设置selectedIndex的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!