Skip to content

sontx/simple-datagridview-paging

Repository files navigation

NuGet

simple-datagridview-paging is a simple UserControl that shows the data-table and paging automatically. With this library, you can also edit the data and it will be saved to the database automatically.

Only ONE line:

dataGridViewPaging.DbRequestHandler = DbRequestHandlerHelper.Create(new SQLiteConnection("Data Source=chinook.db"), "tracks");

Installation

Nuget:

Install-Package SimpleDataGridViewPaging

Or download binary file.

Usage

  1. Add the libary to the ToolBox: Right click to ToolBox -> Choose Item... -> In .Net Framework Components, click on Browse... and select the SimpleDataGridViewPaging.dll file then click OK.
  2. The DataGridViewPaging will be shown in the ToolBox like this:
  3. Drop&drag this control into your form.
  4. Code:
dataGridViewPaging.DbRequestHandler = DbRequestHandlerHelper.Create(new SQLiteConnection("Data Source=chinook.db"), "tracks");

There are two parameters: the connection and the table name that will be shown in the control.

  1. Enjoy ;)

More Options

There are several custom levels:

  1. Read-only mode:
// The first parameter is the database connection,
// the second one is the table name the will be queried and shown in the control.
dataGridViewPaging.DbRequestHandler = DbRequestHandlerHelper.Create(
    new SQLiteConnection("Data Source=chinook.db"),
    "tracks");
  1. Editable mode:
// Like the readonly mode but the third parameter is the CommandBuilder object. 
dataGridViewPaging.DbRequestHandler = DbRequestHandlerHelper.Create(
    new SQLiteConnection("Data Source=chinook.db"),
    "tracks",
    new SQLiteCommandBuilder(new SQLiteDataAdapter()));
  1. Custom query text:
// The libary will use this statement to query the number of records
// that need to caculate the pagination info.
var countStatementBuilder = new CountStatementBuilder();
countStatementBuilder.CommandText("SELECT COUNT(*) FROM tracks");

// This statement will be used to query the actually data of the table.
// There are 3 placeholders: {0} - table name, {1} - max records, {2} - page offset.
// The libary will pass corresponding data to these placeholders on demand.
var rowsStatementBuilder = new RowsStatementBuilder();
rowsStatementBuilder.CommandText("SELECT * FROM tracks LIMIT {1} OFFSET {2}");

dataGridViewPaging1.DbRequestHandler = new DbRequestHandler
{
    Connection = new SQLiteConnection("Data Source=chinook.db"),
    CountStatementBuilder = countStatementBuilder,
    RowsStatementBuilder = rowsStatementBuilder
};
  1. Manual querying. Take a look

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Dependencies

  • .Net Framework 4.5 or later.

Author

Developed by sontx/noem, some useful information:

License

MIT

About

A simple UserControl that shows the data-table and paging automatically with .Net Framework

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy