Solved

Select row from DatagridView C#

Posted on 2009-04-14
2
617 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

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

734 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