DataGrid multiple selection

  • Thread starter Thread starter Fred Stegemann
  • Start date Start date
F

Fred Stegemann

I think there is a bug in DataGrid.IsSelected. This
method apparently returns wrong selection states in most
cases.
Dies anyone know a possibility to manage multiple
selection in datagrid correctly without programming the
whole beheaviour in a derived control?
Thanks for any help
 
Hello Fred,

I cannot reproduce the issue here. Could you provide a sample code to
reproduce that? If so, I like to help to resovle it.

Best regards,

Lion Shi [MSFT]
MCSE, MCSD
Microsoft Support Engineer
Get Secure! ¨C www.microsoft.com/security

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. 2003 Microsoft Corporation. All rights
reserved.
--------------------
| Content-Class: urn:content-classes:message
| From: "Fred Stegemann" <[email protected]>
| Sender: "Fred Stegemann" <[email protected]>
| Subject: DataGrid multiple selection
| Date: Mon, 28 Jul 2003 07:53:58 -0700
| Lines: 7
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcNVGBLhz+YLkYBVTS+ByVN3ZcyIxA==
| Newsgroups: microsoft.public.dotnet.framework.windowsforms
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.windowsforms:49118
| NNTP-Posting-Host: TK2MSFTNGXA14 10.40.1.166
| X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
|
| I think there is a bug in DataGrid.IsSelected. This
| method apparently returns wrong selection states in most
| cases.
| Dies anyone know a possibility to manage multiple
| selection in datagrid correctly without programming the
| whole beheaviour in a derived control?
| Thanks for any help
|
 
Hello Fred,

To make the DataGrid a coincident behavior no matter where the focus is at,
you need to handler all KeyDown events of the child controls inside the
DataGrid. To do this, you may handle the ControlAdded event of the
DataGrid. for all controls added to the DataGrid, add your KeyDown event
handler to the control's KeyDown event

For more detailed information about the ControlAdded event please see:

http://msdn.microsoft.com/library/en-
us/cpref/html/frlrfSystemWindowsFormsControlClassControlAddedTopic.asp

This is a sample code of handling DoubleClick event of the whole DataGrid.:

private void InitializeComponent()
{
this.dataGrid1.DoubleClick += new
System.EventHandler(this.dataGrid1_DoubleClick);
this.dataGrid1.ControlAdded += new
ControlEventHandler(this.dataGrid1_ControlAdded);
}

private void dataGrid1_DoubleClick(object sender, System.EventArgs e)
{
MessageBox.Show("dataGrid1_DoubleClick");
}

private void dataGrid1_ControlAdded(object sender, ControlEventArgs e)
{
e.Control.DoubleClick += new
System.EventHandler(this.dataGrid1_DoubleClick);
}

I hope this helps you.

Best regards,

Lion Shi [MSFT]
MCSE, MCSD
Microsoft Support Engineer
Get Secure! ¨C www.microsoft.com/security

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. 2003 Microsoft Corporation. All rights
reserved.
--------------------
| Content-Class: urn:content-classes:message
| From: "Fred" <[email protected]>
| Sender: "Fred" <[email protected]>
| References: <[email protected]>
<[email protected]>
| Subject: RE: DataGrid multiple selection
| Date: Wed, 6 Aug 2003 02:51:38 -0700
| Lines: 71
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: quoted-printable
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcNcAFTaLtK+C3nnSWCO5iJRXHIJvw==
| Newsgroups: microsoft.public.dotnet.framework.windowsforms
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.windowsforms:49681
| NNTP-Posting-Host: TK2MSFTNGXA13 10.40.1.165
| X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
|
| Hello Lion,
| Sorry, it isn't a problem in the IsSelected method as I
| thought before. It's just, that if the grid has the focus
| and I press return to trigger the default button's click
| event, the selection in the grid is cleared before the
| default button action is entered.
| If I click the button with the mouse, the selection
| beheaviour is correct. Can I handle the return key
| somehow before the grid clears its selection. The KeyDown
| event is apparently not fired for the return key
| Best regards
| Fred
| >-----Original Message-----
| >Hello Fred,
| >
| >I cannot reproduce the issue here. Could you provide a
| sample code to
| >reproduce that? If so, I like to help to resovle it.
| >
| >Best regards,
| >
| >Lion Shi [MSFT]
| >MCSE, MCSD
| >Microsoft Support Engineer
| >Get Secure! ¨C www.microsoft.com/security
| >
| >This posting is provided "AS IS" with no warranties, and
| confers no rights.
| >You assume all risk for your use. 2003 Microsoft
| Corporation. All rights
| >reserved.
| >--------------------
| >| Content-Class: urn:content-classes:message
| >| From: "Fred Stegemann" <[email protected]>
| >| Sender: "Fred Stegemann" <[email protected]>
| >| Subject: DataGrid multiple selection
| >| Date: Mon, 28 Jul 2003 07:53:58 -0700
| >| Lines: 7
| >| Message-ID: <[email protected]>
| >| MIME-Version: 1.0
| >| Content-Type: text/plain;
| >| charset="iso-8859-1"
| >| Content-Transfer-Encoding: 7bit
| >| X-Newsreader: Microsoft CDO for Windows 2000
| >| X-MimeOLE: Produced By Microsoft MimeOLE
| V5.50.4910.0300
| >| Thread-Index: AcNVGBLhz+YLkYBVTS+ByVN3ZcyIxA==
| >| Newsgroups:
| microsoft.public.dotnet.framework.windowsforms
| >| Path: cpmsftngxa06.phx.gbl
| >| Xref: cpmsftngxa06.phx.gbl
| >microsoft.public.dotnet.framework.windowsforms:49118
| >| NNTP-Posting-Host: TK2MSFTNGXA14 10.40.1.166
| >| X-Tomcat-NG:
| microsoft.public.dotnet.framework.windowsforms
| >|
| >| I think there is a bug in DataGrid.IsSelected. This
| >| method apparently returns wrong selection states in
| most
| >| cases.
| >| Dies anyone know a possibility to manage multiple
| >| selection in datagrid correctly without programming
| the
| >| whole beheaviour in a derived control?
| >| Thanks for any help
| >|
| >
| >.
| >
|
 
Back
Top