本文介绍了datagrid中复选框列的索引错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个代码在datagrid的第3列添加一个复选框,但是这列的索引是0而不是3.有没有人理解这个错误以及如何修复它?谢谢



I have this code to add a checkbox to the 3rd column of the datagrid, but the index of this columns is 0 and not 3. Does anyone understand this error and how to fix it? Thanks

public void bloqselect()
       {
           DataGridViewCheckBoxColumn chkSelect = new DataGridViewCheckBoxColumn();
           chkSelect.Selected = false;
           chkSelect.HeaderText = "Bloqueador";
           chkSelect.Name = "chkSelect";
           grid_lic.Columns.Insert(3, chkSelect);

           if (chkSelect.Selected == true)

               bloqueador = 1;

           else
               bloqueador = 0;
       }

推荐答案

grid_lic.Columns.Insert(2, chkSelect);


这篇关于datagrid中复选框列的索引错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-11 11:38