My datagrid context menu does not display if the cursor is
within a cell or the cell text is selected... instead the
standard cut/copy/paste menu is displayed. how do I get
my menu to always show up?

thanks a bunch
mike

RE: override datagrid cell context menu? by lionshi

lionshi
Sun Aug 03 22:53:34 CDT 2003

Hello Michael,

To popup your ContextMenu for the whole DataGrid control, you need to
assign the context menu to each control in your DataGrid control. You may
do this in the ControlAdded event, this is a sample code:

private void InitializeComponent()
{
this.dataGrid1.ContextMenu = this.contextMenu1;
this.dataGrid1.ControlAdded += new
System.Windows.Forms.ControlEventHandler(this.dataGrid1_ControlAdded);
}

private void dataGrid1_ControlAdded(object sender, ControlEventArgs e)
{
e.Control.ContextMenu = contextMenu1;
}

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: "Michael Wortman" <freshg@bpcanada.com>
| Sender: "Michael Wortman" <freshg@bpcanada.com>
| Subject: override datagrid cell context menu?
| Date: Fri, 1 Aug 2003 11:08:48 -0700
| Lines: 7
| Message-ID: <02e101c35857$f4d95a30$a101280a@phx.gbl>
| 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: AcNYV/TZEWg6e9LgSQGL7Y9Wx7i0uA==
| Newsgroups: microsoft.public.dotnet.framework.windowsforms
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.windowsforms:49428
| NNTP-Posting-Host: TK2MSFTNGXA09 10.40.1.161
| X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
|
| My datagrid context menu does not display if the cursor is
| within a cell or the cell text is selected... instead the
| standard cut/copy/paste menu is displayed. how do I get
| my menu to always show up?
|
| thanks a bunch
| mike
|


RE: override datagrid cell context menu? by lionshi

lionshi
Wed Aug 06 21:42:55 CDT 2003

Hello Michael,

Glad to hear it helps :)

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: "freshg" <freshg@bpcanada.com>
| Sender: "freshg" <freshg@bpcanada.com>
| References: <02e101c35857$f4d95a30$a101280a@phx.gbl>
<Yugx9vjWDHA.2080@cpmsftngxa06.phx.gbl>
| Subject: RE: override datagrid cell context menu?
| Date: Wed, 6 Aug 2003 11:41:13 -0700
| Lines: 81
| Message-ID: <021f01c35c4a$4febe1e0$a501280a@phx.gbl>
| 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: AcNcSk/p6Yl5/fE3Sa2/T/O8Jcv1uw==
| Newsgroups: microsoft.public.dotnet.framework.windowsforms
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.windowsforms:49722
| NNTP-Posting-Host: TK2MSFTNGXA13 10.40.1.165
| X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
|
| awesome. that worked perfectly. accomplished exactly
| what I needed.
| Thanks a million
| >-----Original Message-----
| >Hello Michael,
| >
| >To popup your ContextMenu for the whole DataGrid control,
| you need to
| >assign the context menu to each control in your DataGrid
| control. You may
| >do this in the ControlAdded event, this is a sample code:
| >
| >private void InitializeComponent()
| >{
| > this.dataGrid1.ContextMenu = this.contextMenu1;
| > this.dataGrid1.ControlAdded += new
| >System.Windows.Forms.ControlEventHandler
| (this.dataGrid1_ControlAdded);
| >}
| >
| >private void dataGrid1_ControlAdded(object sender,
| ControlEventArgs e)
| >{
| > e.Control.ContextMenu = contextMenu1;
| >}
| >
| >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: "Michael Wortman" <freshg@bpcanada.com>
| >| Sender: "Michael Wortman" <freshg@bpcanada.com>
| >| Subject: override datagrid cell context menu?
| >| Date: Fri, 1 Aug 2003 11:08:48 -0700
| >| Lines: 7
| >| Message-ID: <02e101c35857$f4d95a30$a101280a@phx.gbl>
| >| 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: AcNYV/TZEWg6e9LgSQGL7Y9Wx7i0uA==
| >| Newsgroups:
| microsoft.public.dotnet.framework.windowsforms
| >| Path: cpmsftngxa06.phx.gbl
| >| Xref: cpmsftngxa06.phx.gbl
| >microsoft.public.dotnet.framework.windowsforms:49428
| >| NNTP-Posting-Host: TK2MSFTNGXA09 10.40.1.161
| >| X-Tomcat-NG:
| microsoft.public.dotnet.framework.windowsforms
| >|
| >| My datagrid context menu does not display if the cursor
| is
| >| within a cell or the cell text is selected... instead
| the
| >| standard cut/copy/paste menu is displayed. how do I
| get
| >| my menu to always show up?
| >|
| >| thanks a bunch
| >| mike
| >|
| >
| >.
| >
|