Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Visibility change causes menu items to scroll
Message
De
23/07/2008 18:49:48
 
 
À
22/07/2008 14:39:26
Information générale
Forum:
ASP.NET
Catégorie:
Formulaires
Versions des environnements
Environment:
C# 3.0
OS:
Vista
Divers
Thread ID:
01333256
Message ID:
01333586
Vues:
13
>To reproduce, run code, open file menu, press up and down arrows to move out of menu.
>Menu items are scrolled and blank items appears in end.
>
>I need to change visibility of menu items at runtime.
>How to fix this ?
>Is this .NET 3.5 bug ?


I can reproduce this in VS2005 (and Windows XP), with only .NET 2.0, so this isn't a 3.5 bug. I suspect it's a bug in the MenuStrip, which was new to 2.0.

However, even though it appears that there is a blank item at the end, there really isn't. You can't click on it (at least in my test with .NET 2.0, I couldn't click on it). Yeah, it doesn't look really nice, but off the top of my head I can't figure out a workaround (I really haven't adopted the MenuStrip yet ... we're still using the old MainMenu from 1.1).

But at least it doesn't affect anything negatively, since you can't really click on it ... it merely looks lousy. <g> If I get a chance, I might look at it some more though. If you figure out a workaround before I do, let us know.

~~Bonnie


>
>Andrus.
>
>
>using System.Windows.Forms;
>
>static class Program
>{
>    static void Main()
>    {
>        Application.Run(new Form1());
>    }
>}
>
>class Form1 : Form
>{
>    public Form1()
>    {
>        var menuStrip1 = new MenuStrip();
>        var fileToolStripMenuItem = new ToolStripMenuItem();
>        menuStrip1.Items.AddRange(new ToolStripItem[] { fileToolStripMenuItem });
>        for (int i = 0; i < 10; i++)
>        {
>            var item = new ToolStripMenuItem("Item" + i.ToString());
>            fileToolStripMenuItem.DropDownItems.Add(item);
>            if (i < 5)
>                item.Visible = false;
>        }
>
>        fileToolStripMenuItem.Text = "File";
>        Controls.Add(menuStrip1);
>        MainMenuStrip = menuStrip1;
>    }
>}
>
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform