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

GridViewHyperlinkColumn ignoring TextAlignment...bug??

2 Answers 59 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Rahul
Top achievements
Rank 1
Rahul asked on 21 Jul 2012, 04:38 PM
Hello,

I have Hyperlink columns and am noticing it's just ignoring the TextAlignment property. I changed the "GridViewHyperlinkColumn" to "GridViewTextBoxColumn" and the TextAlignment works just fine.

var column = new GridViewHyperlinkColumn() { FieldName = sColumnNames[i], HeaderText = sColumnDisplayNames[i],
                                                                            HeaderTextAlignment = ContentAlignment.MiddleLeft, TextAlignment = ContentAlignment.MiddleCenter };
        rgvWidget.Columns.Add(column);

2 Answers, 1 is accepted

Sort by
0
Accepted
Stefan
Telerik team
answered on 25 Jul 2012, 12:40 PM
Hi Rahul,

Thank you for writing.

The link in the GridViewHyperlinkColumn resides in a separate element within the GridHyperlinkCellElement, thus the setting of the column does not introduce the desired change - it sets it on the main element only. To achieve the desired appearance, you should handle the CellFormatting event in the following manner:
void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e)
{
    GridHyperlinkCellElement cell = e.CellElement as GridHyperlinkCellElement;
    if (cell != null)
    {
        cell.ContentElement.Alignment = ContentAlignment.MiddleCenter;
    }
}

I will add this as a feature request to our Public Issue Tracking System and we will consider it in a future release. Feel free to add your vote for it here: http://www.telerik.com/support/pits.aspx#/public/winforms/12023.

Your Telerik Points have been updated accordingly.

I hope this helps.

Kind regards,
Stefan
the Telerik team
RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
0
Rahul
Top achievements
Rank 1
answered on 25 Jul 2012, 02:44 PM
That works. Thanks Stefan!

I have also voted for the feature in the PITS system.
Tags
GridView
Asked by
Rahul
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Rahul
Top achievements
Rank 1
Share this question
or