首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

C# dataGirlView控件,该如何处理

2012-06-16 
C# dataGirlView控件这是我在百度知道发表的提问http://zhidao.baidu.com/question/436852705.html?quesup

C# dataGirlView控件
这是我在百度知道发表的提问
http://zhidao.baidu.com/question/436852705.html?quesup2&oldq=1
想这问题想的头晕,不小心点错了。直接采纳了。 我对自己无语了。 但问题没有解决。


这是Form1.cs中的代码

C# code
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.cs 中的代码
C# code
Form2 mf = (Form2)this.Owner;            mf.setData(System.DateTime.Now.ToString(), textBoxAccount.Text, textBoxName.Text, comboBoxString.Text, type, textBoxInitMoney.Text, textBoxInitMoney.Text);


我的代码不对,但又不知道怎么解决。各位网友帮忙看一下。

[解决办法]
public void AddRow(...)
{
datagridview1.Rows.Add();
int rowIndex = datagridview1.RowCount - 1;
DataGridViewRow row = datagridview1.Rows[rowIndex];
row.Cells["Column1"].Value = ...
...
}
[解决办法]
建议你把问题贴出来,就好比你的软件界面,要尽量对用户友好。
你的潜意识就是让回复者复制粘贴你的百度链接查看问题说明,那你为什么不帮他们直接把问题列在贴子上呢?
[解决办法]
已经有你满意答案了不是?不过不能理解为何这样设计
[解决办法]
接6楼,字体样式不能用
C# code
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;} 

热点排行