zhy934453950
zhy934453950
2017-12-05 00:34

求教C#代码报错DataGridViewColumn未将对象引用设置到对象的实例怎么解决?

  • c#
  • datagridview
  • 源码

源码为:
DataGridViewCheckBoxColumn dgcbc1 = new DataGridViewCheckBoxColumn();
dgcbc1.Name = "dgcbc1";
dgcbc1.HeaderText = "选择1";
dgcbc1.DataGridView.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
DataGridViewCheckBoxColumn dgcbc2 = new DataGridViewCheckBoxColumn();
dgcbc2.Name = "dgcbc2";
dgcbc2.HeaderText = "选择2";
dgcbc2.DataGridView.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
DataGridViewCheckBoxColumn dgcbc3 = new DataGridViewCheckBoxColumn();
dgcbc3.Name = "dgcbc3";
dgcbc3.HeaderText = "选择3";
dgcbc3.DataGridView.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
DataGridViewCheckBoxColumn dgcbc4 = new DataGridViewCheckBoxColumn();
dgcbc4.Name = "dgcbc4";
dgcbc4.HeaderText = "选择4";
dgcbc4.DataGridView.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
dataGridView1.Columns.Add(dgcbc1);
dataGridView1.Columns.Add(dgcbc2);
dataGridView1.Columns.Add(dgcbc3);
dataGridView1.Columns.Add(dgcbc4);
图片说明

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

2条回答