Solved

.NET Context Menu Scroll Bars

Posted on 2011-03-11
17
1,404 Views
Last Modified: 2012-06-21
I have an application that dynamically adds values to create a context menu.  This context menu at times can become large...  When it is too large to show in the area of the form that it shows in, rather than showing a vertical scrollbar, it just displays the context menu off of the screen so that the user cannot select those items.

I thought scrollbars would be an automatic for context menus, but I can't find evidence of that.

Is there a way to make the context menu have a vertical scroll bar?

Thanks!
0
Comment
Question by:ablesa
  • 9
  • 8
17 Comments
 
LVL 13

Expert Comment

by:gamarrojgq
ID: 35112209
Hi,

Wich version of VS are you using? in VS2010 is a know bug, and you need to install a hotfix, you can find it in the link below

http://blogs.msdn.com/b/visualstudio/archive/2010/10/14/hotfixes-available-for-scrolling-context-menu-problem.aspx
0
 

Author Comment

by:ablesa
ID: 35112349
I'm using vs2010.  I did read about the bug in VS2010, however, I got the impression that it was just a bug in the IDE...  not necessarily in apps developed with VS2010.  Can you confirm?  If so, I will download that fix...

Many thanks!
0
 
LVL 13

Expert Comment

by:gamarrojgq
ID: 35112493
Well, VS2010 IDE use the same libraries that your project uses to manage the Context Menu, so if the patch fixs the IDE it have to fix you project.

Please download it and try
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

Author Comment

by:ablesa
ID: 35112693
i will give a shot.  thanks!  I'll report back here on whether that resolved.
0
 

Author Comment

by:ablesa
ID: 35129426
I installed the hotfixes for the scroll issue and it does not resolve my problem...  context menus in my app still don't have scrollbars...  And in reading more about the hotfix, it seems to fix a problem opposite of mine.  My problem is that scrollbars don't appear when they need to.  The hotfix addresses a problem where scrollbars appear when they don't need to.
Any other suggestions?

Thanks!
0
 
LVL 13

Expert Comment

by:gamarrojgq
ID: 35129661
Ok, do you really need that the context menu grow that big? can you use Sub menus to prevent the options to be bigger than the screen?

Another thing you can check (just in case) is that the AutoSize and LayoutStyle properties of your Context Menu, are setting to True and Flow

The context Menu won't show you a Standard Scrollbar, but two Up and Down buttons to make the contextmenu scroll
0
 

Author Comment

by:ablesa
ID: 35159010
no... i can't use sub menus...  the context menu is on a grid and it contains items to filter the column by...  In other words, the items on the context menu are all the distinct values in the associated column.  So, if there are a lot of rows in teh grid and a lot of distinct items in teh column, the context menu can be a little big...

It does have autosize=true and layoutstyle = flow.  

Any other ideas?

Thanks for your help.
0
 
LVL 13

Expert Comment

by:gamarrojgq
ID: 35159035
ok, have you tried to installa the application in another machine and see if there happens the same thing?

Perhaps it is only in you environment and will be no problem for your deploy
0
 

Author Comment

by:ablesa
ID: 35198175
I have tried on another machine and the same thing happens...  it just displays the number of items that it can for the screen and the menu is cut-off there...  no up/down buttons and no scrollbar..  
I debugged a little more on this.  When running in debug mode and looking at the ContextMenuStrip, it shows an AutoScroll property set to false.  At design time, I do not see this property on the control.  If I try to set AutoScroll propertty to true in the code, at runtime, I get the error "ToolStrip doesn't support the AutoScroll property."
Not sure what else to try...
0
 
LVL 13

Expert Comment

by:gamarrojgq
ID: 35198605
Ok a ToolStrip is different from a ContextMenuStrip, the ToolStrip is a ToolBar and does not have the AutoScroll property, a ContextMenuStrip if a normal DropDown Menu.

Are you sure you are setting the property to the right control?

Can you post your code to try to see if there is something there?
0
 

Author Comment

by:ablesa
ID: 35207407
I know what the error message says, but this control is really a ContextMenuStrip.  I'm confused as to why the error message refers to a toolStrip.    Yes...I'm setting the property to the right control.  I can't post all of my code.  This is in a user control and there's a lot of code there.  I have attached the code that defines, initializes and assigns it to the grid.
ContextMenuStrip.doc
0
 
LVL 13

Expert Comment

by:gamarrojgq
ID: 35209161
ok, lets try it step by step, in your previous post you said that in debug mode you can see an AutoScroll property set to false right? but this is nota valid property of a ContextMenuStrip, so try to use AutoSize instead.

0
 

Author Comment

by:ablesa
ID: 35210413
AutoSize is already true.  I have attached a screenshot from debugging...
AutoSizeTrue.doc
0
 
LVL 13

Accepted Solution

by:
gamarrojgq earned 500 total points
ID: 35210504
ok, can you post a screenshot of how it looks the contextmenustrip when it is displayed?
0
 

Author Comment

by:ablesa
ID: 35210652
OMG...  I was getting you a screenshot and decided to step further down into the code... I didn't write this particular user control.  Anyway, it turns out that the guy that did write it put a max cap on the number of items it puts on the menu...and that's why they weren't showing up!
I'm so sorry for putting you through this exercise.  I will award the points because I wouldn't have kept digging if you didn't hang in there with me, asking questions...
Appreciate your help!
0
 
LVL 13

Expert Comment

by:gamarrojgq
ID: 35210695
It's not programming fun? :)  Great!!!! glad to help
0
 

Author Comment

by:ablesa
ID: 35210702
If I were having any more fun, I don't think I could stand it.
:)
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
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…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

828 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