Solved

Datagridview doesn't display context menu?

Posted on 2006-11-02
7
402 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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
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…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

820 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