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

Dynamically bestfit columns as user scrolls a grid

2 Answers 119 Views
GridView
This is a migrated thread and some comments may be shown as answers.
SUNIL
Top achievements
Rank 2
Iron
SUNIL asked on 22 Jan 2011, 09:57 PM
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 Answers, 1 is accepted

Sort by
0
Accepted
Alexander
Telerik team
answered on 26 Jan 2011, 01:57 PM
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.
0
SUNIL
Top achievements
Rank 2
Iron
answered on 27 Jan 2011, 07:30 AM
Hi Alexander,

That worked great.

Thanks
Sunil
Tags
GridView
Asked by
SUNIL
Top achievements
Rank 2
Iron
Answers by
Alexander
Telerik team
SUNIL
Top achievements
Rank 2
Iron
Share this question
or