Giter Site home page Giter Site logo

susmitha-sundar / how-to-use-the-gridrecordnavigator-control-in-windows-form-datagrid Goto Github PK

View Code? Open in Web Editor NEW

This project forked from syncfusionexamples/how-to-use-the-gridrecordnavigator-control-in-windows-form-datagrid

0.0 0.0 0.0 13 KB

how to use the gridrecordnavigator control in windows form datagrid

C# 100.00%

how-to-use-the-gridrecordnavigator-control-in-windows-form-datagrid's Introduction

How to use the GridRecordNavigator control in windows form SfDataGrid

About the sample

This example illustrates how to use the GridRecordNavigator control in windows form DataGrid.

By default, SfDataGrid does not support for GridRecordNavigationBar. But we can achieve this by change the selection based on navigation buttons.

Navigate to next row

private void next_Click(object sender, EventArgs e)
{
    var tableControl = this.sfDataGrid1.TableControl;
    if (this.sfDataGrid1.SelectedIndex > -1 && (this.sfDataGrid1.TableControl.ResolveToRowIndex(this.sfDataGrid1.SelectedIndex + 1) != sfDataGrid1.RowCount))
    {
        this.sfDataGrid1.SelectedIndex = this.sfDataGrid1.SelectedIndex + 1;
        selectedIndex = this.sfDataGrid1.SelectedIndex + 1;
        this.sfDataGrid1.TableControl.ScrollRows.ScrollInView(this.sfDataGrid1.CurrentCell.RowIndex);
        this.sfDataGrid1.TableControl.UpdateScrollBars();
        label1.Text = "Record \t" + selectedIndex.ToString() + "of" + (this.sfDataGrid1.TableControl.ScrollRows.LineCount - this.sfDataGrid1.TableControl.ScrollRows.HeaderLineCount);
    }
}

Navigate to previous row

private void previous_Click(object sender, EventArgs e)
{
    if (this.sfDataGrid1.SelectedIndex > 0)
        this.sfDataGrid1.SelectedIndex = this.sfDataGrid1.SelectedIndex - 1;
    selectedIndex = this.sfDataGrid1.SelectedIndex +1;
    this.sfDataGrid1.TableControl.ScrollRows.ScrollInView(this.sfDataGrid1.CurrentCell.RowIndex);
    this.sfDataGrid1.TableControl.UpdateScrollBars();
    label1.Text = "Record \t" + selectedIndex.ToString() + "of" + (this.sfDataGrid1.TableControl.ScrollRows.LineCount - this.sfDataGrid1.TableControl.ScrollRows.HeaderLineCount);
}

Navigate to last row

private void last_Click(object sender, EventArgs e)
{
    var getLastRowIndex = typeof(SelectionHelper).GetMethod("GetLastRowIndex", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static);
    var lastRowIndex = (int)getLastRowIndex.Invoke(typeof(SelectionHelper), new object[] { this.sfDataGrid1 });

    this.sfDataGrid1.SelectedIndex = lastRowIndex - 1;

    this.sfDataGrid1.TableControl.ScrollRows.ScrollInView(this.sfDataGrid1.SelectedIndex);
    this.sfDataGrid1.TableControl.UpdateScrollBars();

    label1.Text = "Record \t" + lastRowIndex.ToString() + "of" + (this.sfDataGrid1.TableControl.ScrollRows.LineCount - this.sfDataGrid1.TableControl.ScrollRows.HeaderLineCount);

} 

Navigate to first row

private void first_Click(object sender, EventArgs e)
{
    var getFirstDataRowIndex = typeof(SelectionHelper).GetMethod("GetFirstRowIndex", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static);
    var firstRowIndex = (int)getFirstDataRowIndex.Invoke(typeof(SelectionHelper), new object[] { this.sfDataGrid1 });

    this.sfDataGrid1.SelectedIndex = firstRowIndex - 1;

    this.sfDataGrid1.TableControl.ScrollRows.ScrollInView(this.sfDataGrid1.SelectedIndex);
    this.sfDataGrid1.TableControl.UpdateScrollBars();
    label1.Text = "Record \t" + firstRowIndex.ToString() + "of" + (this.sfDataGrid1.TableControl.ScrollRows.LineCount - this.sfDataGrid1.TableControl.ScrollRows.HeaderLineCount);
}

Requirements to run the demo

Visual Studio 2015 and above versions

how-to-use-the-gridrecordnavigator-control-in-windows-form-datagrid's People

Contributors

farjanaparveen avatar susmitha-sundar avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.