Solved

Select row from DatagridView C#

Posted on 2009-04-14
2
616 Views
Last Modified: 2013-12-17
I notice when ever I click on a cell it only highlights that particular cell only...

Is there a way to make it when the user clicks on the cell it highlights the entire row?
0
Comment
Question by:csharp_learner
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 250 total points
ID: 24136121
Changing the SelectionMode property of the grid to FullRowSelect should do it.
0
 
LVL 31

Expert Comment

by:RiteshShah
ID: 24136141
use this javascript code and paste it in your .aspx page.

<script language="javascript" type="text/javascript">
       
        var OldColor;
       
        function changeColor(Sender,Mouse)
        {
           
            var Color;
           if(Mouse=="Over")
            {
                OldColor=Sender.bgColor;
                Color="silver";
            }
           else
                Color=OldColor;
           
            Sender.bgColor=Color;
        }
       
        var GridOldColor;
        function GridColorChange(Sender,mouse)
        {
            if(mouse=="Over")
           {
                GridOldColor=Sender.style.backgroundColor;
                Sender.style.backgroundColor="Silver";    
           }
           else
           {
                Sender.style.backgroundColor=GridOldColor;
           }
        }
 </script>


and in your aspx.cs file, have this code

//GVProjectStatus is a name of grid.
protected void GVProjectStatus_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        e.Row.Attributes.Add("onmouseover", "GridColorChange(this,'Over');");
        e.Row.Attributes.Add("onmouseout", "GridColorChange(this,'Out');");
    }
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
how to remove duplicate code from my project 5 48
VB.Net creating Contact in Outlook 1 51
Visual Studio npm 1 29
I need help adding validation to my MVC.Net view 6 21
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question