简体   繁体   中英

c# ms access database error ColumnCount property cannot be set on a data-bound DataGridView control

Please help me to know whats wrong with my code, I'm stuck on this error, So please help me. thanks

       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;

您不需要设置 ColumnCount,只需使用 StudentInfoDataFridView.Columns.Add("whatever");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM