I couldn't find a sample of paging for UltraWinGrid, so I've written one.
This sample simulate paging on client side only, meaning, all data is loaded on startup & displayed in pages.
The sample supports an UltraWinGrid that feeds from MS BindingSource. It also supports DataSource changes (Add\delete\update).
using
{
InitializeComponent();dataGrid =
InitializeComponent();
dataGrid.InitializeRow +=
dataGrid.DataSource = bindingSource;
dataSource.Add(i);
}
dataGrid.DataSource = dataSource;
btnFirstPage.Click +=
btnPreviousPage.Click +=
btnNextPage =
btnLastPage =
btnFirstPage, btnPreviousPage, lblPageNumber, btnNextPage, btnLastPage});
pagingToolbar.Dock =
pagingToolbar.LayoutStyle =
RefreshGrid();
RefreshButtons();
e.Row.Index > (PAGE_SIZE * _currentPage) - 1)
dataGrid.Rows.All.Length > 0)
_currentPage = lastPages;
_currentPage = 1;
_currentPage--;
_currentPage++;
btnPreviousPage.Enabled = _currentPage > 1;
btnFirstPage.Enabled = btnPreviousPage.Enabled;
btnNextPage.Enabled = lastRow.Index > (PAGE_SIZE * _currentPage) - 1;
btnLastPage.Enabled = btnNextPage.Enabled;
Hi,Its great to know this peice of code enables sorting for Ultrawingrid but there are some issues with the codecoz of which i couldnt run it properly.
I am getting following errors.
Error 1 'System.Array' does not contain a definition for 'Last' at _currentPage = (((UltraGridRow)dataGrid.Rows.All.Last()).Index / PAGE_SIZE) + 1;
and another errorError 1 Cannot implicitly convert type 'System.Windows.Forms.ToolStripButton' to 'int' atpagingToolbar = new ToolStrip(new ToolStripItem[btnFirstPage, btnPreviousPage, lblPageNumber, btnNextPage, btnLastPage]);
Thanks in advance,Damu
First error can be fixed easily by adding a using statement to System.Linq. This namespace contains the definition of the Last() extention method.
The second error is just a syntax problem. This is the correct syntax:
pagingToolbar = new ToolStrip(new ToolStripItem[] { btnFirstPage, btnPreviousPage, lblPageNumber, btnNextPage, btnLastPage});