Click here to Skip to main content
15,921,716 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I want when I select a row in the grid the selected row becomes darker
if some one have an idea please help me
Posted
Comments
lukeer 23-Jan-12 9:01am    
Are you talking of a row in DataGridView?
And you don't like the selected row to be painted in your OS's selection colour?
aida1986 23-Jan-12 9:06am    
yes i talk about row in GridControl , and i want to make the selected row in different color

you can use css class

example
XML
<asp:GridView CssClass="GridViewStyle" runat="server" >
    <FooterStyle CssClass="GridViewFooterStyle" />
    <RowStyle CssClass="GridViewRowStyle" />
    <SelectedRowStyle CssClass="GridViewSelectedRowStyle" />
    <PagerStyle CssClass="GridViewPagerStyle" />
    <AlternatingRowStyle CssClass="GridViewAlternatingRowStyle" />
    <HeaderStyle CssClass="GridViewHeaderStyle" />
</asp:GridView>


and style the

CSS
.GridViewSelectedRowStyle
{
    background-color: #666;
    color: #333333;
}



ref http://forums.asp.net/p/1001626/1426529.aspx[^]
 
Share this answer
 
Change your DataGridView's DefaultCellStyle property. It contains settings for selection backcolour.
In the example I did it via subclassing:
C#
class CustomizedDataGridView : DataGridView
{
    protected override void OnCreateControl()
    {
        base.OnCreateControl();

        this.DefaultCellStyle.SelectionBackColor = YourDarkerColour;
        this.DefaultCellStyle.SelectionForeColor = SomeForecolourStillReadable;
    }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900