sinat_36032502
sinat_36032502
2019-05-06 17:18

窗体运用程序中借助dataGridView接收传过来的值是显示未将对象引用设置到对象的实例

  • c#
  • asp.net
  • visual studio

winform设计中借助dataGridView实现窗体传值把值传到主窗体中,
报错显示未将对象引用设置到对象的实例
private void InformationSave_Load(object sender, EventArgs e)
{
//设置列的数目
dataGridView1.ColumnCount = 11;
dataGridView1.ColumnHeadersVisible = true;
//为每一个单元格添加标题
dataGridView1.Columns[0].Name = "图书编号";
dataGridView1.Columns[1].Name = "图书名称";
dataGridView1.Columns[2].Name = "入库时间";
dataGridView1.Columns[3].Name = "图书分类";
dataGridView1.Columns[4].Name = "作者";
dataGridView1.Columns[5].Name = "拼音码";
dataGridView1.Columns[6].Name = "页数";
dataGridView1.Columns[7].Name = "版本";
dataGridView1.Columns[8].Name = "存放位置";
dataGridView1.Columns[9].Name = "图书价格";
dataGridView1.Columns[10].Name = "内容描述";
BookAdd frm = (BookAdd)this.Owner;
try
{
frm.Controls["txtName"].Text = (string)dataGridView1.Rows[1].Cells[0].Value;
}
catch
{
MessageBox.Show("存放失败");
}

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

2条回答