473,659 Members | 3,631 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help in right click menu in c#

HI there,
I need to make the functionality of right clicking on a datagrid cell and try to invoke some menu driven code. It could be a file opening, file saving or my own event driven code. Is this possible, if so can someone help me with some sample code.
Thanks
john
___
Newsgroups brought to you courtesy of www.dotnetjohn.com
Nov 16 '05 #1
2 5419

http://www.knowdotnet.com/articles/d...useselect.html

Selecting a Data Grid Row with Right Mouse Click
by Les Smith
Clicking on a Datagrid row, with the Right Mouse Button,does not
automatically select the clicked row. How can I select the row in a
Datagrid that the user clicks with the Right Mouse Button?


John Rajendran wrote:
HI there,
I need to make the functionality of right clicking on a datagrid cell and
try to invoke some menu driven code. It could be a file opening, file
saving or my own event driven code. Is this possible, if so can someone
help me with some sample code. Thanks john
___
Newsgroups brought to you courtesy of www.dotnetjohn.com


--

http://texeme.com
Textcasting Technology

Nov 16 '05 #2
Hi John,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to add context menu on right
click. If there is any misunderstandin g, please feel free to let me know.

I think we can handle the right click event of each cell's control. Here is
an example:

private void Form1_Load(obje ct sender, System.EventArg s e)
{
this.dataGrid1. ControlAdded +=new
ControlEventHan dler(dataGrid1_ ControlAdded);
}

private void dataGrid1_Contr olAdded(object sender, ControlEventArg s e)
{
if(e.Control is TextBox)
e.Control.Mouse Up +=new MouseEventHandl er(Control_Mous eUp);
}

private void Control_MouseUp (object sender, MouseEventArgs e)
{
if(e.Button == MouseButtons.Ri ght)
MessageBox.Show ("Right Clicked!");
}

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
8004
by: dave | last post by:
I first started using HCW.exe to compile .rtf filew created with MS Word a couple of weeks ago. I used the file | new menu then selected New project in the dialog box and everything worked as expected. After this I decided to TRY to start a new project, so I repeated the File | New menu but for some reason HCW.exe wouldn't allow me to create a new project. After repeating the aforementioned process the filename plus the ..hpj extension...
2
3876
by: Jackson Yap | last post by:
can someone kind enough to help me look at the attached html and js file? Why is it that the javascript menu could not work at www.apchosting.net but could work at http://home.pacific.net.sg/~jacksony ? (the drop down bar could not work at www.apchosting.net but can drop at home.pacific.net.sg. I suspect it is a server problem but was told it is not possible, therefore assuming it is a client script problem? the script works last time...
3
1437
by: Sender | last post by:
The contextmenu I have created has many levels. Like on the main level there are 15 menuitems. Then for each 15 menuitems there are at least 2 menuitems and then for each of these menu items there are further sub-levels. And this process go on for a few more levels. I am accessing this menu from the click of a command button. My form has only this button. Now when I put this form (which is exactly as the size of defaut command button) on...
5
1549
by: A-PK | last post by:
Hi, I am using treeview as my menu. my menu is like the following + Users & Groups - Users -Groups + Departmenuts - Engineering
11
2572
by: Terry Olsen | last post by:
How can I catch a right-click on a DropDownMenuItem?
2
1711
by: Mad Scientist Jr | last post by:
I am editing an existing application that has a System.Windows.Forms.TreeView with a right-click menu with several options. I want to get rid of the TreeView alltogether and rip out the code for the right-click options and put these under different command buttons instead, but I am having trouble finding the code for the options. I remember in VB6 there was some kind of menu editor which gave the name of the subs for the menu options,...
5
3848
by: james | last post by:
Hello, I am having a little trouble creating an event handler for a context menu toolstripmenuitem. I've seen various tutorials and so on, but I keep getting a bit stuck! So far I have a second class defining the eventargs I want to use: public class ApptEventArgs : EventArgs{ public int ApptUID; public String ApptOp;
1
4084
by: =?Utf-8?B?SkQ=?= | last post by:
ok, I got a windows xp home edition computer from my friend, it is a custom made one. The windows xp is an OEM product, so microsoft is willing to charge me $59 to tell me how to fix it since its not insured... I searched under Find Error Message on the site and it wasn't there. I get this error message " Error, No Program start menu found." whenever i try to install something onto my computer. I put the disk into the tray, and a window...
0
8428
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8337
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8531
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8628
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5650
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2754
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1978
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1739
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.