Change Row Color On Select In VB.Net Gridview Control

I would like to change this color when I Select a row. At the moment the color is a Dark Blue which is not good aesthetics (in my opinion). Can somebody help me please.

Many thanks
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Avinash DesaiSr Software EngineerCommented:

In the SelectedIndexChanged Event of the DataGridview   [Windows Application]


NolancAuthor Commented:

Hi Avinesh

I cannot find such an event of my Gridview. I find SelectionChanged and TabIndexChanged but not the one you are proposing. I am using Visual Studio 2008. Any Ideas ?.

Avinash DesaiSr Software EngineerCommented:
You are doing it on windows or web application ?

That above code works for windows application and for web application use below code

Private Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs)

   If e.Row.RowType = DataControlRowType.DataRow Then

            e.Row.BackColor = Drawing.Color.Red

   End If

End Sub

And Even Check out this link
OWASP Proactive Controls

Learn the most important control and control categories that every architect and developer should include in their projects.

NolancAuthor Commented:
Hi Avinash

My application is a Windows one. Sorry, I should have told you this. Despite repeated checks, I do not find the event SelectedIndexChanged under my Gridview events.

Avinash DesaiSr Software EngineerCommented:
The windows the first code works fine

In the Properties Under Rows change the Selection back color then it works fine or else

check out these links below which helps for sure

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
NolancAuthor Commented:
Hi Avinash
Thanks for your help. In my Load Event I used the following Statement:

MyGrid.DefaultCellStyle.SelectionBackColor = MyColor

Avinash DesaiSr Software EngineerCommented:
Hi Nolanc

welcome buddy :)


Avinash desai
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.