Solved

Datagridview doesn't display context menu?

Posted on 2006-11-02
7
399 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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now