关于c#下datagridview 绑定打他table后运行可以有显示内容,但是datagridview返回行和列都为0
大虾帮忙了,这个问题我已经研究了两天了,渴望被解决呀。。DataGridView tableView2 = new DataGridView();
tableView2.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
tableView2.Location = new System.Drawing.Point(34, 121);
tableView2.Name = "tableView2";
tableView2.RowTemplate.Height = 23;
tableView2.Size = new System.Drawing.Size(1511, 721);
tableView2.TabIndex = 4;
SqlDataGV yuantou = new SqlDataGV();//自建的查询数据库表格后做各类操作
DataTable zz = yuantou.dtTest();//类下的方法返回操作后返回表格一枚传给datagridview做源使用
BindingSource bind = new BindingSource();
bind.DataSource = zz;
tableView2.DataSource = null;
tableView2.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader);
tableView2.AutoGenerateColumns = true;
tableView2.DataSource = bind;
Console.WriteLine(tableView2.Rows.Count + " ");//显示行数为0,列数同样为0
因为返回的行数和列数为零,所以在做表格操作时会出现超出索引的问题。烦死了,等着大虾帮忙呀。麻烦了。 datagridview c#
补充:.NET技术 , C#