将新行添加到数据表的顶部 [英] Adding new row to datatable's top
本文介绍了将新行添加到数据表的顶部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我们使用datatable.newrow命令时,新的空行添加到行的底部。但是我希望将newrow添加到datatable的顶部。我该怎么做?
When we use datatable.newrow command, a new empty row added to bottom of rows. However I want newrow to added to top of datatable. How can I make it?
推荐答案
您使用NewRow创建具有相同列的行。要真正将其放入数据表,必须要做的
You use the NewRow to create a row with the same columns. To actually get it into the DataTable, you've got to do
myDataTable.Rows.InsertAt(myDataRow, 0);
其中0是要插入索引的位置。
Where 0 is the index you want to insert it at.
这篇关于将新行添加到数据表的顶部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文