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

Styling problem centering a CheckBox column created dynamically

3 Answers 43 Views
TreeListView
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 11 Oct 2011, 07:54 PM

I have been try to center a dynamically create checkbox column with the checkbox centered. If you create it in design time, it is centered. When I create it dynamically in the Page_Load event I get the checkbox left justified. I created it as follows:

checkBoxColumn = New TreeListCheckBoxColumn()

treeList.Columns.Add(checkBoxColumn)

checkBoxColumn.DataField = "Accessibility"

checkBoxColumn.UniqueName = "Accessibility"

checkBoxColumn.HeaderText = "Accessibility"

checkBoxColumn.ItemStyle.HorizontalAlign = HorizontalAlign.Center

 

It works, just not centered. Any ideas as to why I cannot center the checkbox?

Thanks,

Paul

3 Answers, 1 is accepted

Sort by
0
Vanya Pavlova
Telerik team
answered on 11 Oct 2011, 08:28 PM
Hi Paul,

 
If you want to center the CheckBox in a column you should define a cell style and set the HorizontalContentAlignment property to Center:

<UserControl.Resources>
   <Style x:Key="style1" TargetType="telerik:GridViewCell">
    <Setter Property="HorizontalContentAlignment" Value="Center"/>
   </Style>
</UserControl.Resources>

Finally you may set this style in code-behind to the column as shown below: 

column.CellStyle=this.Resources["style1"] as Style;

Best wishes,
Vanya Pavlova
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Paul
Top achievements
Rank 1
answered on 12 Oct 2011, 01:06 PM

My code behind is in VB. I tried the following:

 

Dim checkBoxColumn As New TreeListCheckBoxColumn()

tcConfig.Columns.Add(checkBoxColumn)

checkBoxColumn.DataField = "Accessibility"

checkBoxColumn.UniqueName = "Accessibility"

checkBoxColumn.HeaderText = "Accessibility"

checkBoxColumn.CellStyle = Resources("style1")

 

I am getting an error:

‘CellStyle’ is not a member of ‘Telerik.Web.UI.TreeListCheckBoxColumn’.


I then tried,


checkBoxColumn.ItemStyle.CssClass = Resources("style1")

 


with the user control resources in the aspx page and also in the Web.config file. Either way ‘Resources’ was not found.

0
Vlad
Telerik team
answered on 12 Oct 2011, 01:09 PM
Hi,

 This forum is for our Silverlight products only. Please post your questions in the relevant category!

Greetings,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
TreeListView
Asked by
Paul
Top achievements
Rank 1
Answers by
Vanya Pavlova
Telerik team
Paul
Top achievements
Rank 1
Vlad
Telerik team
Share this question
or