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

ColumnWidthChangedEventArgs - Values do not reflect the new state of the column!

1 Answer 33 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Rob
Top achievements
Rank 1
Rob asked on 30 Mar 2011, 10:32 PM
Hello,

I am working inside a ColumnWidthChanged event and attempting to get the "new" column width (as a double-pixel value) of the resized column.  In my particular scenario, the user has double clicked the resize handle which changes the width to "Auto"...

The only value that I can find by inspecting the ColumnWidthChangedEventArgs object is the original pixel value which as of this point in execution has not been updated (which is strange because this is the "Changed" event...)

Am I doing something incorrectly?  Or is this a bug?  Or is there another way to grab the new width (as a pixel value) inside the ColumnWidthChanged event? 

Thanks,
Rob

1 Answer, 1 is accepted

Sort by
0
Tsvyatko
Telerik team
answered on 05 Apr 2011, 08:55 AM
Hello Rob,

ColumnWidthChanged is fired once user tries to resize or double click on the resizer. As you have found out it contains information about the original and the current column width. When user resizes  the column using drag the current width can be measured in absolute units (pixels). However, if the user double-clicks the width become auto (fit to contents) and thus it cannot be measured in absolute units until the measures finishes.

If we need to acquire the absolute width of the column after the measure is complete I can suggest using code similar to the one below:

if(e.NewWidth.IsAuto)
{
      this.radGridView.Dispatcher.BeginInvoke((Action)(()=>YourMethodHere(e.Column.ActualWidth)));
}

Kind regards,
Tsvyatko
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
Rob
Top achievements
Rank 1
Answers by
Tsvyatko
Telerik team
Share this question
or