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

Row background Color

5 Answers 1378 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Smayr
Top achievements
Rank 1
Smayr asked on 25 Sep 2013, 08:30 AM


Hello I have a problem when mouse over RowFormatting radgrid the entire row background color disapear
below is my code

Private Sub gridview_RowFormatting(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.RowFormattingEventArgs) Handles GVClaimHistory.RowFormatting

        If InStr(e.RowElement.RowInfo.Cells(0).Value, "MyColumn") <> 0 Then
            e.RowElement.DrawFill = True
            e.RowElement.GradientStyle = GradientStyles.Solid
            e.RowElement.BackColor = Color.Navy
            e.RowElement.ForeColor = Color.Yellow
        End If
    End Sub

please help

5 Answers, 1 is accepted

Sort by
0
Smayr
Top achievements
Rank 1
answered on 25 Sep 2013, 10:57 AM
solved like this    Gridview .EnableHotTracking = False
0
James
Top achievements
Rank 1
answered on 07 Oct 2013, 03:52 PM
I'm new to using Telerik products so please forgive my inexperience.
I'm not quite understanding when the CellFormattingEventArgs gets handled?
I used to be able to set the row color with 1 line of code but I'm not able to do this with a radgridview.
My Code snippet shows when I need to set the backcolor of the current row.

Thanks

 

Public Sub DataGridView2_CellContentClick(ByVal sender As System.Object, ByVal e As Telerik.WinControls.UI.GridViewCellEventArgs) Handles DataGridView2.CellClick
    Dim I As Integer
 
    If e.ColumnIndex = 0 Then
        If sps_EIPHasBeenBilled(DataGridView2.CurrentRow.Cells("PolNo").Value.ToString) Then
            frmRenewalsPersonalMarkComplete.Show()
        Else
            MsgBox("Unable to Mark This Policy as Complete! Reason: " & DataGridView2.CurrentRow.Cells("PolNo").Value.ToString & " Has Not been Billed Yet.", vbOKOnly)
        End If
    ElseIf e.ColumnIndex = 1 Then
        StrTabsWCSource = "Renewal"
         
                         'Set backcolor of current row
        If frmTabsWC.Visible Then
            frmTabsWC.FormLoad()
        Else
            frmTabsWC.Show()
        End If
    End If
End Sub

 

 

 

 

 

0
George
Telerik team
answered on 10 Oct 2013, 03:57 PM
Hello James,

Thank you for writing.

In our documentation we have articles for both - Formatting Rows and Formatting cells. You can find them respectively on the following addresses:
The CellFormatting/RowFormatting events are fired when a Cell/Row has to be formatted, for example on cell click or when scrolling.

Let me know If you require additional assistance.

Regards,
George
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Shraddha
Top achievements
Rank 1
answered on 21 Feb 2014, 10:48 AM
Hi friends,

I m changing grid row backcolor by using below code and its successful 

if e.RowElement.RowInfo.Index  =1 then
     e.RowElement.BackColor = red
     e.RowElement.GradientStyle = GradientStyles.Solid
     e.RowElement.DrawFill = True
end if

but my problem is when i do mouseover it spreads color in other rows also how to stop that!

i did following settings but no  luck

Gridview .EnableHotTracking = False



0
George
Telerik team
answered on 26 Feb 2014, 08:39 AM
Hi Shraddha,

Thank you for contacting us.

You need to reset these values if the condition is not true as per the following help articles:

Your code should look like this:
If e.RowElement.RowInfo.Index  = 1 Then
    e.RowElement.BackColor = red
    e.RowElement.GradientStyle = GradientStyles.Solid
    e.RowElement.DrawFill = True
Else
    e.RowElement.ResetValue(VisualElement.BackColorProperty, ValueResetFlags.Local)
    e.RowElement.ResetValue(LightVisualElement.GradientStyleProperty, ValueResetFlags.Local)
    e.RowElement.ResetValue(LightVisualElement.DrawFillProperty, ValueResetFlags.Local)
EndIf

I hope this helps.

Regards,
George
Telerik
Tags
GridView
Asked by
Smayr
Top achievements
Rank 1
Answers by
Smayr
Top achievements
Rank 1
James
Top achievements
Rank 1
George
Telerik team
Shraddha
Top achievements
Rank 1
Share this question
or