473,408 Members | 1,771 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

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 5408

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 misunderstanding, 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(object sender, System.EventArgs e)
{
this.dataGrid1.ControlAdded +=new
ControlEventHandler(dataGrid1_ControlAdded);
}

private void dataGrid1_ControlAdded(object sender, ControlEventArgs e)
{
if(e.Control is TextBox)
e.Control.MouseUp +=new MouseEventHandler(Control_MouseUp);
}

private void Control_MouseUp(object sender, MouseEventArgs e)
{
if(e.Button == MouseButtons.Right)
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
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...
2
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...
3
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...
5
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
by: Terry Olsen | last post by:
How can I catch a right-click on a DropDownMenuItem?
2
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...
5
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...
1
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...
0
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...

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.