Solved

Datagridview doesn't display context menu?

Posted on 2006-11-02
7
401 Views
Last Modified: 2012-05-05
I have a simple test app with one form, one datagridview, and a
contextmenustrip.  I've assigned the menustrip to the datagridview and
given the grid one column.  There isn't any data in the grid.  I never
see the context menu appear when I right click the grid.  Any
suggestions?

Thanks,
Brett
0
Comment
Question by:brettr
7 Comments
 
LVL 15

Accepted Solution

by:
mattisflones earned 200 total points
ID: 17864257
A: You did something wrong..

Thats all the help you can get if you dont post code, or elaborate on the problem..
Ex: No data? Why? Was the GridView supposed to display data? How did you "assign" the menustrip to the GridView?


0
 

Author Comment

by:brettr
ID: 17864306
All of this is at design time.  There's no data because I'm just trying to get this to work in the simplest scenario.  It doesn't work in a more complex environment so I want to get at the smallest parts and work up from there.

I did all the assignments at design time so there isn't any code.  The datagridview and contextmenustrip were both dropped on a form.
0
 
LVL 8

Expert Comment

by:sabeesh
ID: 17864913
You have to set DataGrid.contextmenu property

DataGrid.contextmenu  = contextmenu
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 29

Expert Comment

by:Gautham Janardhan
ID: 17865778
1) u got to have items in the contextmenu otherwise it wont popup
 2) u have to set the context menu property of data grid as ur context menu.

this should solve ur problem.
0
 

Author Comment

by:brettr
ID: 17866445
This is not a datagrid with a contextmenu.  It is a datagridview with a contextmenustrip.  The menu has menu items and I have assigned it to the grid's contextmenustrip.  No go.
0
 

Author Comment

by:brettr
ID: 17869965
Ok, my fault all the way around.  At design time, I need to add a
toolstripmenuitem to my contextmenustrip.  It looked like an item was
already there at design time in it's collection.  But once I clicked
Add (from clicking the collection property), I saw a child appear and
new that was my mistake.

The problem at run time is the datagridview will allow you to set
grid.contextmenu and fully intialize menu items.  However, I can't get
it to work at all.  This property isn't available at design
time...oddly.  But if you follow the above for contextmenustrip, it
also works at runtime.

Does any one know if a datagridview's context menu property actually
works, similar to a regular datagrid.contextmenu.

Thanks and sorry for the hassle.  I'm awarding points to the first person since every one else keeps referring to a datagrid.  Please "carefully" read the post before responding.

Brett
0
 
LVL 15

Expert Comment

by:mattisflones
ID: 17870240
:-)

Crap happends...

"Does any one know if a datagridview's context menu property actually
works, similar to a regular datagrid.contextmenu."

It should.. atleast thats what the documentation says!


0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Error in JQuery 5 52
Video Player 2017 5 22
What can cause the styling on a .NET site to not be found? 17 25
Printing 1 51
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question