Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ToolStripMenuItem.visible always false

Posted on 2006-11-23
5
Medium Priority
?
2,646 Views
Last Modified: 2008-07-09
Hello

I have a problem with the "visible" attribute of ToolStripMenuItem.

I have a form with a ToolStrip containing two ToolStripMenuItem buttons. I've been setting the visible attribute of these two buttons to false depending on the users permissions.
I'm now trying to re-size the ToolStrip according to how many of the buttons are visible. The problem occurs when I come to test the value of ToolStripMenuItem.visible.
It always seems to be false until the form has completeley finished drawing. So I can't count how many of the buttons are going to be visible.

How can I accurately test the visible attribute of a ToolStripMenuItem ?
0
Comment
Question by:Rusty_Adams
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 12

Accepted Solution

by:
sumix earned 500 total points
ID: 18006116
It is true, visible property of ToolStripMenuItems is false until the form is loaded. You should handle Load event of the form and set there this property.

Note: ToolStripMenuItem can be part of a MenuStrip or a ContextMenuStrip control. If you use a ToolStrip containing ToolStripButtons you have ToolStrip.AutoSize property you can use, but again, visible property for ToolStripButtons should be set in Load event.
0
 

Author Comment

by:Rusty_Adams
ID: 18006359
Thankyou

Using the load event of the form solved my problem.
Although I don't see how the ToolStrip.AutoSize is of any use. I still had to re-size the tool strip myself.
At what point is the AutoSize property supposed to take effect?

0
 
LVL 12

Expert Comment

by:sumix
ID: 18006370
By default, ToolStrip has Dock property set to Top or Bottom. The resize can only take place if Dock is set to None, otherwise the size is linked with the size of the container.
0
 

Author Comment

by:Rusty_Adams
ID: 18006438
That's strange. My toolstrip is not docked at all, and AutoSize is set to true. Yet it doesn't appear to perform any sort of auto re-size.
0
 
LVL 10

Expert Comment

by:smegghead
ID: 21966266
It seems that the 'Available' property reflects whether the item has been set to visible or not.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
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
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

719 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