//Pagination code BindingNavigator1.BindingSource = BindingSource1; BindingSource1.CurrentChanged += BindingNavigator1_CurrentChanged; BindingSource1.DataSource = new PageOffsetList { TotalRecords = myDataTable.Rows.Count, //The dataTable PageSize = pageSize }; //Grid binding private void BindingNavigator1_CurrentChanged(object sender, EventArgs e) { // The desired page has changed, so fetch the page of records using the "Current" offset if (myDataTable!= null) { var offset = (int)BindingSource1.Current; var dataTable = myDataTable.Clone(); dataTable.Rows.Clear(); totalRecords = myDataTable.Rows.Count; for (int i = offset; i < offset + pageSize && i < totalRecords; i++) { dataTable.ImportRow(myDataTable.Rows[i]); } BindingSource bs = new BindingSource(); bs.DataSource = dataTable.DefaultView; DataView1.DataSource = bs; } }
// Add the AutoFilter header cell to each column. var col = ValidateGrid.Columns["Column1"]; col.HeaderCell = new DataGridViewAutoFilterColumnHeaderCell(col.HeaderCell); col = ValidateGrid.Columns["Column2"]; col.HeaderCell = new DataGridViewAutoFilterColumnHeaderCell(col.HeaderCell);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)