Dynamically bestfit columns as user scrolls a grid

3 posts, 1 answers
  1. Sunil
    Sunil avatar
    230 posts
    Member since:
    Jan 2004

    Posted 22 Jan 2011 Link to this post

    I would like to bestfit all the columns dynamically as user scrolls a grid vertically.
    I don't know if this is at all possible, since there seems no event that is called in grid when user scrolls it vertically.

    I am using Q1 2008 SP1 radgridview.

    Thanks
    Sunil
  2. Answer
    Alexander
    Admin
    Alexander avatar
    306 posts

    Posted 26 Jan 2011 Link to this post

    Hello Sunil,

    Thank you for your question.

    You can use the ValueChanged event of the GridElement vertical scrollbar to implement logic when the user scrolls the control. The following code snippet demonstrates this approach:
    this.radGridView1.GridElement.VScrollBar.ValueChanged += new EventHandler(VScrollBar_ValueChanged);
     
    private void VScrollBar_ValueChanged(object sender, EventArgs e)
    {
        RadScrollBarElement scrollBar = this.radGridView1.GridElement.VScrollBar;
        this.radGridView1.MasterGridViewTemplate.BestFitColumns();
    }

    I hope it helps.

    Best regards,
    Alexander
    the Telerik team
    Q3’10 SP1 of RadControls for WinForms is available for download; also available is the Q1'11 Roadmap for Telerik Windows Forms controls.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Sunil
    Sunil avatar
    230 posts
    Member since:
    Jan 2004

    Posted 27 Jan 2011 Link to this post

    Hi Alexander,

    That worked great.

    Thanks
    Sunil
Back to Top