C# dataGirlView控件
这是我在百度知道发表的提问
http://zhidao.baidu.com/question/436852705.html?quesup2&oldq=1
想这问题想的头晕,不小心点错了。直接采纳了。 我对自己无语了。 但问题没有解决。
这是Form1.cs中的代码
public void setData(string time, string username,string name,string type,string leibie,string money,string moneylast ) { dataGridView1.Rows[rowIndex].Cells["Column1"].Value = time; dataGridView1.Rows[rowIndex].Cells["Column2"].Value = username; dataGridView1.Rows[rowIndex].Cells["Column3"].Value = name; dataGridView1.Rows[rowIndex].Cells["Column4"].Value = type; dataGridView1.Rows[rowIndex].Cells["Column5"].Value = leibie; dataGridView1.Rows[rowIndex].Cells["Column6"].Value = money; dataGridView1.Rows[rowIndex].Cells["Column7"].Value = moneylast; rowIndex++; }
Form2 mf = (Form2)this.Owner; mf.setData(System.DateTime.Now.ToString(), textBoxAccount.Text, textBoxName.Text, comboBoxString.Text, type, textBoxInitMoney.Text, textBoxInitMoney.Text);
public void setData(string time, string username, string name, string type, string leibie, string money, string moneylast){ int index = this.dataGridView1.Rows.Add(); dataGridView1.Rows[index].Cells["Column1"].Value = time; dataGridView1.Rows[index].Cells["Column2"].Value = username; dataGridView1.Rows[index].Cells["Column3"].Value = name; dataGridView1.Rows[index].Cells["Column4"].Value = type; dataGridView1.Rows[index].Cells["Column5"].Value = leibie; dataGridView1.Rows[index].Cells["Column6"].Value = money; dataGridView1.Rows[index].Cells["Column7"].Value = moneylast;}