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

GridViewComboBoxColumn Text Alignment

3 Answers 231 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Lee
Top achievements
Rank 1
Lee asked on 21 Jul 2010, 08:05 PM
How do you change the text alignment for the text displayed in a GridViewComboBoxColumn in a RadGridView?

I've tried to set TextAlignment="Right" but the text in the combo is always left aligned.

Thanks.


3 Answers, 1 is accepted

Sort by
0
Accepted
Milan
Telerik team
answered on 22 Jul 2010, 11:01 AM
Hello Lee Weisenberger,

Setting HorizontalContentAlignment instead of HorizontalAlignment will resolve the problem. 

<telerik:GridViewDataColumn DataMemberBinding="{Binding Name}">
    <telerik:GridViewDataColumn.CellStyle>
        <Style TargetType="telerik:GridViewCell">
            <Setter Property="HorizontalContentAlignment" Value="Right"/>
        </Style>
    </telerik:GridViewDataColumn.CellStyle>
</telerik:GridViewDataColumn>


Best wishes,
Milan
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
0
Vic
Top achievements
Rank 1
Iron
answered on 09 Sep 2014, 07:42 PM
When specifying a CellStyle as suggested above (using Build 2014.2.0617), I find that it also affects the placement of the editor control (RadComboBox) so that it no longer stretches to fit the width of the cell.  Specifying an EditorStyle or CellEditTemplate to override this behavior has no effect.  Is there another solution?

I am trying to avoid creating a CellTemplate for this column as it complicates the databinding.

Thanks..
0
Yoan
Telerik team
answered on 12 Sep 2014, 12:57 PM
Hi,

I would suggest you to use a regular GridViewDataColumn and place a RadCombobox in its CellEditTemplate. Then you can set the TextAlignment property of the column to "Right":
<telerik:GridViewDataColumn DataMemberBinding="{Binding Name}"
 UniqueName="Name"
 TextAlignment="Right"
                    <telerik:GridViewDataColumn.CellEditTemplate>
                        <DataTemplate>
                            <telerik:RadComboBox ItemsSource="{Binding Clubs,Source={StaticResource MyViewModel}}"
             HorizontalContentAlignment="Stretch"
             SelectedIndex="0"
             SelectedValuePath="Name"/>
                        </DataTemplate>
                    </telerik:GridViewDataColumn.CellEditTemplate>
                </telerik:GridViewDataColumn>


Please give it a try and let me know how it works for you.

Regards,
Yoan
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
GridView
Asked by
Lee
Top achievements
Rank 1
Answers by
Milan
Telerik team
Vic
Top achievements
Rank 1
Iron
Yoan
Telerik team
Share this question
or