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

Get Border Color for Theme

2 Answers 313 Views
Themes and Visual Style Builder
This is a migrated thread and some comments may be shown as answers.
Florian
Top achievements
Rank 1
Florian asked on 10 Sep 2015, 03:43 PM

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

But the BorderColor was never set to the default.

Thanks for any help.

2 Answers, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 15 Sep 2015, 09:26 AM
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()
        InitializeComponent()
 
        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))
        Next
 
        Return dt
    End Function
 
    Private Sub Button1_Click(sender As Object, e As EventArgs)
        Me.RadGridView1.ClearSelection()
    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.

Regards,
Hristo Merdjanov
Telerik
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
0
Florian
Top achievements
Rank 1
answered on 15 Sep 2015, 12:33 PM
Thank you, works perfect
Tags
Themes and Visual Style Builder
Asked by
Florian
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Florian
Top achievements
Rank 1
Share this question
or