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

[Solved] Auto resize a column

1 Answer 148 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Amit Patel
Top achievements
Rank 1
Amit Patel asked on 25 Feb 2010, 03:53 PM
How can i get the column to auto resize? if the user types long name i want it column to adjust according to string length. (This behavior works right now) but if user decides to go back to original length (the short length), i want column to adjust back to smaller size. (this one does not work)?

Thanks,
Amit

1 Answer, 1 is accepted

Sort by
0
Accepted
Stefan Dobrev
Telerik team
answered on 02 Mar 2010, 10:30 AM
Hello Amit,

Currently there is not built-in way to make this work. However you can use a simple trick with CellEditEnded event of RadGridView. Here is a sample snippet illustrating this:
...
this.playersGrid.CellEditEnded += playersGrid_CellEditEnded;
...
 
void playersGrid_CellEditEnded(object sender, GridViewCellEditEndedEventArgs e)
{
    //Set some dummy width in order to trigger property changed
    e.Cell.Column.Width = 100;
    e.Cell.Column.Width = GridViewLength.Auto;
     
}

Greetings,
Stefan Dobrev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
GridView
Asked by
Amit Patel
Top achievements
Rank 1
Answers by
Stefan Dobrev
Telerik team
Share this question
or