zhy934453950
2017-12-05 00:34
采纳率: 50%
浏览 2.0k

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

源码为:
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条回答 默认 最新

相关推荐 更多相似问题