This is a migrated thread and some comments may be shown as answers.

Adding custom paging selection to gridView

2 Answers 56 Views
GridView
This is a migrated thread and some comments may be shown as answers.
vfa
Top achievements
Rank 1
vfa asked on 21 Oct 2016, 10:35 AM

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 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 21 Oct 2016, 11:11 AM
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.
0
vfa
Top achievements
Rank 1
answered on 24 Oct 2016, 08:31 AM
Thank you very much. This is exactly what I needed.
Tags
GridView
Asked by
vfa
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
vfa
Top achievements
Rank 1
Share this question
or