Change Row Color On Select In VB.Net Gridview Control


Hi
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
NolancAsked:
Who is Participating?
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:
Hi

In the SelectedIndexChanged Event of the DataGridview   [Windows Application]

DataGridview1.CurrentRow.Backcolor=Color.Red

0
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 ?.

Thanks
0
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

http://www.codeproject.com/KB/grid/GridViewRowColor.aspx
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

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.

Thanks
0
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

http://social.msdn.microsoft.com/Forums/en/vbgeneral/thread/22c39e54-42d6-48a5-abf3-da9433d2a8a8

http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewcellstyle.selectionbackcolor.aspx
0

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

Thanks
0
Avinash DesaiSr Software EngineerCommented:
Hi Nolanc

welcome buddy :)

Regards

Avinash desai
0
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.