Column Header Click Event? (DataGrid) 
Author Message
 Column Header Click Event? (DataGrid)

Hi There!

I've got to do selection on my DataGrid control data.
But selection is cleared when user clicks on Column Header.
Is there any event which i can use?

Thanx for any help

Marcin Grzbski



Mon, 02 May 2005 21:13:37 GMT  
 Column Header Click Event? (DataGrid)
Hello,

This is because when you click the header of DataGrid, all rows will be
sorted and the indices will be changed. Hence, the previous selection is
not available. To work around this, you may handle the MouseDown event and
determine if the header is clicked. If not, then save the current selected
indices into a temp array, otherwise reselect these indices by code. This
is a sample code:

private void dataGrid1_MouseDown(object sender,
System.Windows.Forms.MouseEventArgs e)
{
        if(dataGrid1.HitTest(new Point(e.X, e.Y)).Row == -1)
                ResoreSelectedIndices();
        else
                SaveSelectIndices();

Quote:
}

I hope it helps you.

Best regards,

Lion Shi [MS]
MCSE, MCSD
Microsoft Support Engineer

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use.  2001 Microsoft Corporation. All rights
reserved.
--------------------

    Newsgroups:
microsoft.public.dotnet.framework.adonet,microsoft.public.dotnet.languages.c
sharp
    Subject: Column Header Click Event? (DataGrid)
    Date: Thu, 14 Nov 2002 14:13:37 +0100
    Organization: tp.internet - http://www.tpi.pl/
    Lines: 10

    NNTP-Posting-Host: 217.96.29.199
    Mime-Version: 1.0
    Content-Type: text/plain; charset=ISO-8859-2; format=flowed
    Content-Transfer-Encoding: 8bit
    X-Trace: news2.tpi.pl 1037279344 26763 217.96.29.199 (14 Nov 2002
13:09:04 GMT)

    NNTP-Posting-Date: Thu, 14 Nov 2002 13:09:04 +0000 (UTC)
    X-Accept-Language: en-us, en
    User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.1)
Gecko/20020826
    Path:
cpmsftngxa09!cpmsftngxa08!tkmsftngp01!newsfeed00.sul.t-online.de!newsfeed01.
sul.t-online.de!t-online.de!newsfeed.tpinternet.pl!news.tpi.pl!not-for-mail
    Xref: cpmsftngxa09 microsoft.public.dotnet.languages.CSharp:108207
microsoft.public.dotnet.framework.adonet:37339
    X-Tomcat-NG: microsoft.public.dotnet.languages.csharp

    Hi There!

    I've got to do selection on my DataGrid control data.
    But selection is cleared when user clicks on Column Header.
    Is there any event which i can use?

    Thanx for any help

    Marcin Grzbski



Fri, 06 May 2005 11:11:57 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. How to get the clicked column number or column header text in CListctl(report view)

2. datagrid column header text alignment

3. get the names of the columns in my datagrid header (windows forms)

4. Double clicking column header of ListView

5. Problem in sorting list control by clicking column header

6. DataGrid Click Event

7. Datagrid cell click event in c#

8. DataGrid's Click event fires before setting the current row's focus

9. datagrid click event not triggering

10. Capture click/double-click events from datatable

11. Double Click fires two single click events??

12. Why Mouse Mouse event with every Click event

 

 
Powered by phpBB® Forum Software