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

Column chooser Content Alignment

1 Answer 77 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Matt
Top achievements
Rank 1
Matt asked on 16 Dec 2015, 11:08 PM

I am trying to left align the text in the column chooser. When I walk through it debugging, I can see the value successfully get updated but the content is still middle aligned when shown. What is the correct way to left align the text in column chooser?

This is what I am currently doing, the positioning portion works correctly but not the content alignment.

private void ConfigureOrderGrid()
{
        orders_radGridView.ColumnChooser.Shown += (o, args) =>   orders_radGridView.ColumnChooser.SetPosition();
}
 
public static void SetPosition(this GridViewColumnChooser chooser)
{           
    var gridPoint = chooser.GridRootElement.PointToScreen(new Point(0));
    var x = gridPoint.X + chooser.GridRootElement.Size.Width;
    chooser.DesktopLocation = new Point(x, gridPoint.Y);
    chooser.StartPosition = FormStartPosition.Manual;
    chooser.ColumnChooserControl.ColumnChooserElement.TextAlignment =   ContentAlignment.MiddleLeft;
}

 

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 17 Dec 2015, 06:42 AM
Hi Matt,

Thank you for writing.

The column chooser is being dynamically created when opened, your settings are getting applied just the first time - because radGridView1.ColumnChooser will give you just the initial instance, and you are not subscribed to the Shown event of following instances.

For the we have a ColumnChooserCreated event, which gets fired when a new instance of the chooser is being created. In it, you can subscribe to the Shown event and use your handler:
void ColumnChooser_Shown(object sender, EventArgs e)
{
    var gridPoint = radGridView1.ColumnChooser.GridRootElement.PointToScreen(new System.Drawing.Point(0));
    var x = gridPoint.X + radGridView1.ColumnChooser.GridRootElement.Size.Width;
    radGridView1.ColumnChooser.DesktopLocation = new System.Drawing.Point(x, gridPoint.Y);
    radGridView1.ColumnChooser.StartPosition = FormStartPosition.Manual;
    radGridView1.ColumnChooser.ColumnChooserControl.ColumnChooserElement.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
}
 
void radGridView1_ColumnChooserCreated(object sender, ColumnChooserCreatedEventArgs e)
{
    e.ColumnChooser.Shown+=ColumnChooser_Shown;
}

I hope that you find this information useful. Should you have any other questions, do not hesitate to contact us.

Regards,
Stefan
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
GridView
Asked by
Matt
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or