Solved

Select row from DatagridView C#

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

746 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now