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

2 posts, 0 answers
  1. kronnos_indigo
    kronnos_indigo avatar
    61 posts
    Member since:
    Jul 2006

    Posted 24 Jun 2010 Link to this post

    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 
          '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

  2. Maya
    Maya avatar
    4062 posts

    Posted 25 Jun 2010 Link to this post

    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:

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

    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)
    End Sub

    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
  3. DevCraft banner
Back to Top