Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Cannot seem to Cancel EXCEL App Right Click Event using C#

I am trying to use Excel from C# and need to disable the menu that appears when clicking the right mouse button on a cell.

I am trying to do this using the Excel.AppEvents_SheetBeforeRightClickEventHandler from my C# WinForm application.

I have a MessageBox that pops up that proves my event handler actually fires via my delegate but after setting the "Cancel" variable to "true" it has no effect for me. The Excel RMB menu appears when it should not. The Cancel parameter is declared as "ref bool".

I am wondering if there is a problem with the marshalling of this variable in the Office PIA which I am using. I would be happy to send code that demos my problem. Can someone please let me know if they can make it work ?

By the way I have already written some VB6 code that works fine and VBA code in an Excel Workbook that also works just fine as well. Both disable the menu as I require when I set "Cancel" to "True". The problem is that I need to do this from a C# application.

Can anyone shed some light on this at all ?

I am using...

Microsoft Excel 2002 (10.4302.4219) SP-2
Visual Studio 2003 v7.1.3088
Microsoft .NET Framework 1.1 v1.1.4322

I obtained the Office XP Primary Interop Assemblies from the following link

http://www.microsoft.com/downloads/d...displaylang=en


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 400
Default Cannot seem to Cancel EXCEL App Right Click Event using C#

I don't believe you can disable the right click on the activesheet. If you set the AllowPropertyToolbox to false, it disables the Property Toolbox on the right click menu. There is no other property that can be set. The list of properties is:

ActiveCell ActivePane ActiveSheet
AllowPropertyToolbox AutoFit BuildNumber
CSVData CSVURL CanUndo
Cells Columns Constants
DataType Dirty DisplayColHeaders
DisplayGridlines DisplayHorizontalScrollBar DisplayPropertyToolbox
DisplayRowHeaders DisplayTitleBar DisplayToolbar
DisplayVerticalScrollBar EnableAutoCalculate EnableEvents
EnableUndo HTMLData HTMLURL
MajorVersion MaxHeight MaxWidth
MinorVersion MoveAfterReturn MoveAfterReturnDirection
Range RevisionNumber RightToLeft
Rows ScreenUpdating Selection
TitleBar Version ViewableRange

I can't see that there is a right click event.The list of events is:

BeforeCommand Calculate CancelEdit
Change Click Command
DblClick EndEdit KeyDown
KeyPress KeyUp MouseDown
MouseOut MouseOver MouseUp
SelectionChange SelectionChanging StartEdit
ViewChange

Like you, I think the OWC PIA is screwed up. Can you help with my post "OWC Web Component Spreadsheet: C#" in this news group?
"Nick Biggs" wrote:

I am trying to use Excel from C# and need to disable the menu that appears when clicking the right mouse button on a cell.

I am trying to do this using the Excel.AppEvents_SheetBeforeRightClickEventHandler from my C# WinForm application.

I have a MessageBox that pops up that proves my event handler actually fires via my delegate but after setting the "Cancel" variable to "true" it has no effect for me. The Excel RMB menu appears when it should not. The Cancel parameter is declared as "ref bool".

I am wondering if there is a problem with the marshalling of this variable in the Office PIA which I am using. I would be happy to send code that demos my problem. Can someone please let me know if they can make it work ?

By the way I have already written some VB6 code that works fine and VBA code in an Excel Workbook that also works just fine as well. Both disable the menu as I require when I set "Cancel" to "True". The problem is that I need to do this from a C# application.

Can anyone shed some light on this at all ?

I am using...

Microsoft Excel 2002 (10.4302.4219) SP-2
Visual Studio 2003 v7.1.3088
Microsoft .NET Framework 1.1 v1.1.4322

I obtained the Office XP Primary Interop Assemblies from the following link

http://www.microsoft.com/downloads/d...displaylang=en


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Cannot seem to Cancel EXCEL App Right Click Event using C#



"AA2e72E" wrote:

I don't believe you can disable the right click on the activesheet. If you set the AllowPropertyToolbox to false, it disables the Property Toolbox on the right click menu. There is no other property that can be set. The list of properties is:

ActiveCell ActivePane ActiveSheet
AllowPropertyToolbox AutoFit BuildNumber
CSVData CSVURL CanUndo
Cells Columns Constants
DataType Dirty DisplayColHeaders
DisplayGridlines DisplayHorizontalScrollBar DisplayPropertyToolbox
DisplayRowHeaders DisplayTitleBar DisplayToolbar
DisplayVerticalScrollBar EnableAutoCalculate EnableEvents
EnableUndo HTMLData HTMLURL
MajorVersion MaxHeight MaxWidth
MinorVersion MoveAfterReturn MoveAfterReturnDirection
Range RevisionNumber RightToLeft
Rows ScreenUpdating Selection
TitleBar Version ViewableRange

I can't see that there is a right click event.The list of events is:

BeforeCommand Calculate CancelEdit
Change Click Command
DblClick EndEdit KeyDown
KeyPress KeyUp MouseDown
MouseOut MouseOver MouseUp
SelectionChange SelectionChanging StartEdit
ViewChange

Like you, I think the OWC PIA is screwed up. Can you help with my post "OWC Web Component Spreadsheet: C#" in this news group?
"Nick Biggs" wrote:

I am trying to use Excel from C# and need to disable the menu that appears when clicking the right mouse button on a cell.

I am trying to do this using the Excel.AppEvents_SheetBeforeRightClickEventHandler from my C# WinForm application.

I have a MessageBox that pops up that proves my event handler actually fires via my delegate but after setting the "Cancel" variable to "true" it has no effect for me. The Excel RMB menu appears when it should not. The Cancel parameter is declared as "ref bool".

I am wondering if there is a problem with the marshalling of this variable in the Office PIA which I am using. I would be happy to send code that demos my problem. Can someone please let me know if they can make it work ?

By the way I have already written some VB6 code that works fine and VBA code in an Excel Workbook that also works just fine as well. Both disable the menu as I require when I set "Cancel" to "True". The problem is that I need to do this from a C# application.

Can anyone shed some light on this at all ?

I am using...

Microsoft Excel 2002 (10.4302.4219) SP-2
Visual Studio 2003 v7.1.3088
Microsoft .NET Framework 1.1 v1.1.4322

I obtained the Office XP Primary Interop Assemblies from the following link

http://www.microsoft.com/downloads/d...displaylang=en


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Cannot seem to Cancel EXCEL App Right Click Event using C#

I think you're speaking the Greek here!

But I can disable the rightclick option on a worksheet by disabling the "Cell"
commandbar.

Maybe it'll work for you:

Dim myIndex As Long
myIndex = Application.CommandBars("cell").Index
Application.CommandBars(myIndex).Enabled = False
Application.CommandBars(myIndex + 3).Enabled = False

The +3 refers to the "cell" commandbar when you're in View|PageBreak Preview
mode.

(Don't forget to turn it back to True when you're done. This setting will be
kept the next time excel opens!)

Nick Biggs wrote:

I am trying to use Excel from C# and need to disable the menu that appears when clicking the right mouse button on a cell.

I am trying to do this using the Excel.AppEvents_SheetBeforeRightClickEventHandler from my C# WinForm application.

I have a MessageBox that pops up that proves my event handler actually fires via my delegate but after setting the "Cancel" variable to "true" it has no effect for me. The Excel RMB menu appears when it should not. The Cancel parameter is declared as "ref bool".

I am wondering if there is a problem with the marshalling of this variable in the Office PIA which I am using. I would be happy to send code that demos my problem. Can someone please let me know if they can make it work ?

By the way I have already written some VB6 code that works fine and VBA code in an Excel Workbook that also works just fine as well. Both disable the menu as I require when I set "Cancel" to "True". The problem is that I need to do this from a C# application.

Can anyone shed some light on this at all ?

I am using...

Microsoft Excel 2002 (10.4302.4219) SP-2
Visual Studio 2003 v7.1.3088
Microsoft .NET Framework 1.1 v1.1.4322

I obtained the Office XP Primary Interop Assemblies from the following link

http://www.microsoft.com/downloads/d...displaylang=en


--

Dave Peterson

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Cannot seem to Cancel EXCEL App Right Click Event using C#



"Nick Biggs" wrote:

I am trying to use Excel from C# and need to disable the menu that appears when clicking the right mouse button on a cell.

I am trying to do this using the Excel.AppEvents_SheetBeforeRightClickEventHandler from my C# WinForm application.

I have a MessageBox that pops up that proves my event handler actually fires via my delegate but after setting the "Cancel" variable to "true" it has no effect for me. The Excel RMB menu appears when it should not. The Cancel parameter is declared as "ref bool".

I am wondering if there is a problem with the marshalling of this variable in the Office PIA which I am using. I would be happy to send code that demos my problem. Can someone please let me know if they can make it work ?

By the way I have already written some VB6 code that works fine and VBA code in an Excel Workbook that also works just fine as well. Both disable the menu as I require when I set "Cancel" to "True". The problem is that I need to do this from a C# application.

Can anyone shed some light on this at all ?

I am using...

Microsoft Excel 2002 (10.4302.4219) SP-2
Visual Studio 2003 v7.1.3088
Microsoft .NET Framework 1.1 v1.1.4322

I obtained the Office XP Primary Interop Assemblies from the following link

http://www.microsoft.com/downloads/d...displaylang=en




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cancel sheet change event NSK Charts and Charting in Excel 1 July 17th 07 08:25 PM
On Click Event?, and how to use Wandering Mage Excel Programming 5 June 7th 04 04:28 PM
Cancel terminate event?? Pop Excel Programming 1 May 19th 04 12:00 PM
Before Right Click event mohsinb[_8_] Excel Programming 10 December 22nd 03 08:47 AM
Click Event Nichevo Excel Programming 2 December 4th 03 04:31 AM


All times are GMT +1. The time now is 02:58 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"