Click here to Skip to main content
15,891,316 members
Home / Discussions / C#
   

C#

 
AnswerRe: Avoiding exceptions in socket programming Pin
Not Active3-Sep-10 1:06
mentorNot Active3-Sep-10 1:06 
GeneralRe: Avoiding exceptions in socket programming Pin
Rob Philpott3-Sep-10 1:10
Rob Philpott3-Sep-10 1:10 
GeneralRe: Avoiding exceptions in socket programming Pin
#realJSOP3-Sep-10 1:36
mve#realJSOP3-Sep-10 1:36 
AnswerRe: Avoiding exceptions in socket programming Pin
DaveyM693-Sep-10 1:35
professionalDaveyM693-Sep-10 1:35 
QuestionToolStripMenuItem.Visible always returns false? (Clarified hopefully) Pin
AussieLew2-Sep-10 17:53
AussieLew2-Sep-10 17:53 
AnswerRe: ToolStripMenuItem.Visible always returns false? (Clarified hopefully) Pin
Matt U.2-Sep-10 17:59
Matt U.2-Sep-10 17:59 
GeneralRe: ToolStripMenuItem.Visible always returns false? (Clarified hopefully) Pin
AussieLew2-Sep-10 18:45
AussieLew2-Sep-10 18:45 
AnswerRe: ToolStripMenuItem.Visible always returns false? (Clarified hopefully) Pin
DaveyM695-Sep-10 7:20
professionalDaveyM695-Sep-10 7:20 
This is the correct behaviour. As the parent menu item isn't visible, it is impossible for the child to be visible therefore setting the Visible property has no effect.

You should either:

1. Set the visibility of the higher items first.
2. Use the Enabled property instead. You could iterate over all the items and set Visible based on Enabled.

C#
private void SetMenuItemsVisiblity(MenuStrip menuStrip)
{
    foreach (ToolStripMenuItem item in menuStrip.Items)
    {
        item.Visible = item.Enabled;
        if (item.Visible && item.DropDownItems.Count > 0)
            SetToolStripMenuItemVisiblity(item);
    }
}
private void SetToolStripMenuItemVisiblity(ToolStripMenuItem item)
{
    foreach (ToolStripMenuItem subItem in item.DropDownItems)
    {
        subItem.Visible = subItem.Enabled;
        if (subItem.Visible && item.DropDownItems.Count > 0)
            SetToolStripMenuItemVisiblity(subItem);
    }
}

Dave

If this helped, please vote & accept answer!


Binging is like googling, it just feels dirtier.
Please take your VB.NET out of our nice case sensitive forum.(Pete O'Hanlon)

BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)

GeneralRe: ToolStripMenuItem.Visible always returns false? (Clarified hopefully) Pin
AussieLew6-Sep-10 1:49
AussieLew6-Sep-10 1:49 
GeneralRe: ToolStripMenuItem.Visible always returns false? (Clarified hopefully) Pin
DaveyM696-Sep-10 2:34
professionalDaveyM696-Sep-10 2:34 
GeneralRe: ToolStripMenuItem.Visible always returns false? (Clarified hopefully) Pin
AussieLew6-Sep-10 23:38
AussieLew6-Sep-10 23:38 
QuestionPDF based project Pin
AussieLew2-Sep-10 17:41
AussieLew2-Sep-10 17:41 
Questionwhat's in DragEventArgs in a dragdrop event Pin
Louis-Etienne Chicoine2-Sep-10 8:53
Louis-Etienne Chicoine2-Sep-10 8:53 
AnswerRe: what's in DragEventArgs in a dragdrop event Pin
Luc Pattyn2-Sep-10 9:02
sitebuilderLuc Pattyn2-Sep-10 9:02 
QuestionHow do I convert an XML response of type GetLiveCompactWeatherByUSZipCodeResponse into usable strings? Pin
SCADirector2-Sep-10 6:18
SCADirector2-Sep-10 6:18 
QuestionIs there a good example of using multiple forms..... Pin
glennPattonWork32-Sep-10 5:11
professionalglennPattonWork32-Sep-10 5:11 
AnswerRe: Is there a good example of using multiple forms..... Pin
phil.o2-Sep-10 5:31
professionalphil.o2-Sep-10 5:31 
GeneralRe: Is there a good example of using multiple forms..... Pin
glennPattonWork32-Sep-10 6:17
professionalglennPattonWork32-Sep-10 6:17 
GeneralRe: Is there a good example of using multiple forms..... Pin
#realJSOP2-Sep-10 7:10
mve#realJSOP2-Sep-10 7:10 
GeneralRe: Is there a good example of using multiple forms..... Pin
The Man from U.N.C.L.E.2-Sep-10 7:11
The Man from U.N.C.L.E.2-Sep-10 7:11 
AnswerRe: Is there a good example of using multiple forms..... Pin
Henry Minute2-Sep-10 6:22
Henry Minute2-Sep-10 6:22 
AnswerRe: Is there a good example of using multiple forms..... Pin
DaveyM692-Sep-10 6:24
professionalDaveyM692-Sep-10 6:24 
GeneralRe: Is there a good example of using multiple forms..... Pin
AussieLew2-Sep-10 18:53
AussieLew2-Sep-10 18:53 
GeneralRe: Is there a good example of using multiple forms..... Pin
DaveyM692-Sep-10 21:18
professionalDaveyM692-Sep-10 21:18 
GeneralRe: Is there a good example of using multiple forms..... Pin
glennPattonWork32-Sep-10 23:40
professionalglennPattonWork32-Sep-10 23:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.