Adding custom paging selection to gridView

3 posts, 0 answers
  1. vfa
    vfa avatar
    2 posts
    Member since:
    Oct 2011

    Posted 21 Oct Link to this post

    I want to implement the possibility to allow the user to chose the page size for GridView. My Idea is to add a textbox or dropdownlost next to the textbox with the current page number.

     

    How can this be done? I have tried but didn't find the solution by myself.

     

    Thank you

  2. Dimitar
    Admin
    Dimitar avatar
    1414 posts

    Posted 21 Oct Link to this post

    Hello Andrea,

    The following snippet shows how you can achieve this:
    public Form1()
    {
        InitializeComponent();
       
        CommandBarDropDownButton button = new CommandBarDropDownButton();
        button.Text = "PageSize";
        button.DrawText = true;
        button.DrawImage = false;
        button.StretchHorizontally = false;
      
        for (int i = 0; i < 5; i++)
        {
            RadMenuItem item = new RadMenuItem();
            item.Text = (i + 1) + "0";
            item.Click += item_Click;
            button.Items.Add(item);
        }
        radGridView1.GridViewElement.PagingPanelElement.TextBoxStripElement.Items.Add(button);
    }
    void item_Click(object sender, EventArgs e)
    {
        int pageSize = Convert.ToInt32(((RadMenuItem)sender).Text);
        radGridView1.MasterTemplate.PageSize = pageSize;
    }

    Should you have any other questions do not hesitate to ask.

    Regards,
    Dimitar
    Telerik by Progress
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. vfa
    vfa avatar
    2 posts
    Member since:
    Oct 2011

    Posted 24 Oct in reply to Dimitar Link to this post

    Thank you very much. This is exactly what I needed.
Back to Top