you don't need to use DataSource to add a row, for example, Table t = (Table)MyDataGrid.Controls[0];
DataGridItem tr = new DataGridItem(0,0,ListItemType.Item);
for (int i=0; i < MyDataGrid.Items[0].Cells.Count; i++)
{
TableCell tc = new TableCell();
tc.Text = "....";
tr.Cells.Add(tc);
} t.Rows.AddAt(n+1, tr);
DataGridItem tr = new DataGridItem(0,0,ListItemType.Item);
for (int i=0; i < MyDataGrid.Items[0].Cells.Count; i++)
{
TableCell tc = new TableCell();
tc.Text = "....";
tr.Cells.Add(tc);
} t.Rows.AddAt(n+1, tr);
解决方案 »
- Unable to connect to any of the specified MySQL hosts为什么连不上mysql?
- 来帮忙看看这个功能怎么实现。
- ASPxNavBar的 GROUP里面放一个Treeview
- cs文件编译提示说:不包含 LoadXml 方法怎么解决 ?
- DataGrid的难问题!急~~~~~
- 验证表单概念问题 FormsAuthenticationTicket
- 如何用asp.net发传真?
- 订单编号怎么写?用Mssql或者是C#的
- 思归,孟子&其他高手,第一次取cookies值是乱码,第二次编译就对了。
- 有何不同
- 非典调查,各地疫情
- 还是不太明白C#(.NET)能作些什么。
Thanks so much for ur help,I do appreciate it.I'll try it later.TY again.
---------------------------------------------------------------------------------
To saucer(思归, MS .NET MVP):
---------------------------------------------------------------------------------
我想是我没有表达清楚,用你的方法是能插入新行,一点问题都没有,但现在的问题在于插入的新行中显示了所有的列,而我只要在我点击的按纽下面新增一行,这里面只有一列(因为“发送内容”项内容较长,如再加上上面的那些列的话就不够显示了。)。如何实现上述功能?请继续指教,谢谢!
DataGridItem tr = new DataGridItem(0,0,ListItemType.Item);
TableCell tc = new TableCell();
tc.ColumnSpan = MyDataGrid.Items[0].Cells.Count; tc.Text = "....";
tr.Cells.Add(tc);
t.Rows.AddAt(n+1, tr);
谢谢,可以了,麻烦再请问一下,你是如何知道可以用TableCell的这个属性的呢?也就是说,如果再遇到类似的问题,是不是可以在MSDN中的什么地方或是其他地方去找呢?
Thanks for ur help!