Get Border Color for Theme

3 posts, 0 answers
  1. Florian
    Florian avatar
    14 posts
    Member since:
    Dec 2014

    Posted 10 Sep 2015 Link to this post

    Since GridView.ClearSelection Method is totaly crap(See attached file: NoSelectionFormatting.png)

    i need to handle the rowformatting and cellformattiong when no Selection on gridview is done.

    Removing the Backcolor was not the problem. But now i need to get the Default Border Color for GridViewCells and GridViewRows when its not selected.(See attached file: NoSelectionFormattingV1.png)

    I am using Windows8 Theme in my application but this could be different for other customers, so i tried to get the Theme for the Current Theme like that:


    Dim theme As Theme = ThemeResolutionService.GetTheme(ThemeResolutionService.ApplicationThemeName)


    Just for testing if the Propertys exists that i need i implemented the following code:

    Dim styleGroup As StyleGroup = theme.FindStyleGroup("Telerik.WinControls.UI.RadGridView")
    For Each propertyGroup In styleGroup.PropertySettingGroups
        For Each setting In propertyGroup.PropertySettings
            Select Case setting.Name
                Case "BorderColor"
                    e.RowElement.BorderColor = setting.Value
                Case "BorderColor2"
                    e.RowElement.BorderColor2 = setting.Value
                Case "BorderColor3"
                    e.RowElement.BorderColor3 = setting.Value
                Case "BorderColor4"
                    e.RowElement.BorderColor4 = setting.Value
            End Select

    But the BorderColor was never set to the default.

    Thanks for any help.

  2. Hristo
    Hristo avatar
    1504 posts

    Posted 15 Sep 2015 Link to this post

    Hello Florian,

    Thank you for writing.

    The ClearSelection method of RadGridView empties the SelectedRows collection. However, as you have observed, boundary lines of the current row remain. In order to remove it, you would need to set the CurrentRow to null. Please see my code snippet below: 
    Public Class Form1
        Inherits Form
        Public Sub New()
            Me.RadGridView1.DataSource = Me.GetData()
            Me.RadGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill
        End Sub
        Private Function GetData() As DataTable
            Dim dt As New DataTable()
            dt.Columns.Add("Name", GetType(String))
            dt.Columns.Add("Age", GetType(Integer))
            dt.Columns.Add("Date", GetType(DateTime))
            dt.Columns.Add("Bool", GetType(Boolean))
            For i As Integer = 0 To 9999
                dt.Rows.Add("Name " + i, i, DateTime.Now.AddMinutes(i), If(i Mod 2 = 0, True, False))
            Return dt
        End Function
        Private Sub Button1_Click(sender As Object, e As EventArgs)
        End Sub
        Private Sub Button2_Click(sender As Object, e As EventArgs)
            Me.RadGridView1.CurrentRow.IsCurrent = False
        End Sub
    End Class

    I am also sending you a gif file showing the result on my end.

    I hope this helps. Should you have further questions please do not hesitate to write back.

    Hristo Merdjanov
    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 Feedback Portal and vote to affect the priority of the items
  3. Florian
    Florian avatar
    14 posts
    Member since:
    Dec 2014

    Posted 15 Sep 2015 Link to this post

    Thank you, works perfect
Back to Top