日期:2014-05-17 浏览次数:21439 次
DataTable dt = (DataTable)dataGridView1.DataSource;
dataGridView1.DataSource = ??.Skip<PeopleInfo>(pageSize * pageNum)
.Take<PeopleInfo>(pageSize);
var nt = dt.Clone();
dt.Rows.OfType<DataRow>()
.Skip(pageSize * ( pageNum-1) )
.Take(pageSize )
.ToList()
.ForEach(r => nt.Rows.Add(r));
using System.Data;
using System.Linq;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
var dg = new DataGridView();
dg.Dock = DockStyle.Fill;
Controls.Add(dg);
var dt = new DataTable {Columns = {new DataColumn("c1"), new DataColumn("c2")}};
dt.Rows.Add(1, 2);
dt.Rows.Add(3, 4);
dt.Rows.Add(5, 6);
dg.DataSource = dt.AsEnumerable().Skip(1).CopyToDataTable();