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

How to define FONT and font properties in a Column Add in runtime?

1 Answer 71 Views
GridView
This is a migrated thread and some comments may be shown as answers.
kronnos_indigo
Top achievements
Rank 2
kronnos_indigo asked on 24 Jun 2010, 09:44 PM
Good Afternoon Team Teleri
In  my page of SilverLigth, I add and remove any columns in runtime by programming. :
Private Sub adicionarColumnas(ByVal grilla As Telerik.Windows.Controls.RadGridView, ByVal nombreColumna As String, _ 
                                ByVal encabezado As String, ByVal ancho As Integer) 
    Dim m, d As String, p As Integer 
    m = "adicionarColumnas)-" : d = "Entra" : p = 0 
    Try 
      'MessageBox.Show(o & vbCrLf & m & p & d, "", MessageBoxButton.OK) 
      Dim columna As New Telerik.Windows.Controls.GridViewDataColumn 
      p = 40 : columna.UniqueName = nombreColumna 
      p = 50 : columna.Header = encabezado 
      p = 100 : columna.IsVisible = True 
      p = 125 : columna.IsReadOnly = True 
      p = 128 : columna.Width = ancho 
      p = 150 : columna.DataMemberBinding = New System.Windows.Data.Binding(nombreColumna) 
      p = 160 : grilla.Columns.Add(columna) 
    Catch ex As Exception 
      MessageBox.Show("Revisar: " & o & vbCrLf & m & p & vbCrLf & ex.Message) 
    End Try 
    d = ") Sale " 
    'p = 999 : MessageBox.Show(o & vbCrLf & m & p & d) 
  End Sub 
but How do I define the font and font properties (fontname, fontsize, etc) to new column?

Thanks for any help.

Juan Pablo Díaz
Bogotá D.C. Colombia


1 Answer, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 25 Jun 2010, 04:39 PM
Hello kronnos_indigo,

 
You can define the desired style for the GridViewCell of the column you are creating programatically and set it as a its CellStyle. For example:

<UserControl.Resources>    
        <Style x:Key="NewColumnStyle" TargetType="telerik:GridViewCell">
            <Setter Property="FontSize" Value="34" />
        </Style>
    </UserControl.Resources>

And then in the code-behind:
Private Sub AddColumn(sender As Object, e As RoutedEventArgs)
    Dim newColumn As New GridViewDataColumn()
    newColumn.DataMemberBinding = New Binding("Name")
    newColumn.CellStyle = DirectCast(Me.Resources("NewColumnStyle"), Style)
    Me.playersGrid.Columns.Add(newColumn)
End Sub


Regards,
Maya
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
Tags
GridView
Asked by
kronnos_indigo
Top achievements
Rank 2
Answers by
Maya
Telerik team
Share this question
or