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

how to set TextAlignment in GridViewCommandColumn

1 Answer 216 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Judas Trujillo
Top achievements
Rank 1
Judas Trujillo asked on 19 Oct 2007, 05:38 PM
Hello.

I have a Windows Form and a RadGridView (with default theme), I added some columns manually using the RadGridView Property Builder (not from a database table or any datasource) and then I added a GridViewCommandColumn.

The problem is when I set the TextAlignment property of  Telerik.WinControls.UI.GridViewCommandColumn to MiddleCenter (with DefaultText = "Print", UseDefaultText = True), the alignment doesn't change and the text in the GridViewCommandColumn is always aligned to MiddleLeft.

am I setting the TextAlignment in the wrong place?

Thanks in advance.

1 Answer, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 22 Oct 2007, 01:15 PM
Hello Judas Trujillo,

You have set the TextAlignment at the right place. Unfortunately, there is an issue with the GridViewCommandColumn. It does not respond to changes in the value of the TextAlignment property. We will fix this in our next service pack.

Thank you for reporting this issue. For the time being, you can use the workaround shown in the code below (You must include the both lines to enforce layout update):

 
this.radGridView1.CellFormatting += new CellFormattingEventHandler(radGridView1_CellFormatting); 
 
private void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e) 
    if (e.CellElement is GridCommandCellElement) 
    { 
        if (e.CellElement.Children.Count > 0 && e.CellElement.Children[0] is RadButtonElement) 
        { 
            ((RadButtonElement)e.CellElement.Children[0]).TextAlignment = ContentAlignment.BottomRight; 
            ((RadButtonElement)e.CellElement.Children[0]).TextAlignment = ContentAlignment.MiddleCenter; 
        } 
    } 
 
 
Your Telerik points have been updated.

Don't hesitate to contact us if you have other questions.

Best wishes,
Jack
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
GridView
Asked by
Judas Trujillo
Top achievements
Rank 1
Answers by
Jack
Telerik team
Share this question
or