c#ms访问数据库错误无法在数据绑定的DataGridView控件上设置ColumnCount属性

时间:2015-09-11 07:39:21

标签: c#

请帮助我知道我的代码有什么问题,我坚持这个错误,所以请帮助我。感谢

       InitializeComponent();


        studentInfoDataGridView.ColumnCount = 6;
        studentInfoDataGridView.Columns[0].Name = "ID";
        studentInfoDataGridView.Columns[1].Name = "FirstName";
        studentInfoDataGridView.Columns[2].Name = "LastName";
        studentInfoDataGridView.Columns[3].Name = "Course";
        studentInfoDataGridView.Columns[4].Name = "StudentSection";
        studentInfoDataGridView.Columns[5].Name = "StudentNumber";



        studentInfoDataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;

        studentInfoDataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
        studentInfoDataGridView.MultiSelect = false;

1 个答案:

答案 0 :(得分:0)

您不需要设置ColumnCount,只需使用即可 StudentInfoDataFridView.Columns.Add("无论&#34);