Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
DotNet
acad.assignment.mngr
academic
adonet
aspnet
aspnet.announcements
aspnet.build.controls
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
clr
compactframework
component_services
datatools
distributed_apps
drawing
faqs
framework
framework.wmi
general
internationalization
interop
languages.csharp
languages.jscript
languages.vb
languages.vb.controls
languages.vb.data
languages.vb.upgrade
languages.vc
languages.vc.libraries
myservices
odbcnet
performance
remoting
scripting
sdk
security
setup
vjsharp
vsa
webservi.enhancements
webservices
windowsforms
windowsforms.controls
winforms.databinding
winforms.designtime
xml
  
 
date: Tue, 22 Jul 2008 21:32:41 +0300,    group: microsoft.public.dotnet.languages.csharp        back       


Visibility change causes menu items to scroll (bug?)   
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 ?

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;
    }
}
date: Tue, 22 Jul 2008 21:32:41 +0300   author:   Andrus

Re: Visibility change causes menu items to scroll (bug?)   
Andrus,

    The only immediate workaround I can see would be to not add the items if 
you are not going to make them visible.  I took your example and didn't add 
the items if they were not visible, and didn't get that effect.

    I would definitely register this bug on the Microsoft Connect site.


-- 
          - Nicholas Paldino [.NET/C# MVP]
          - mvp@spam.guard.caspershouse.com

"Andrus"  wrote in message 
news:%23uod8lC7IHA.3652@TK2MSFTNGP04.phx.gbl...
> 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 ?
>
> 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;
>    }
> }
>
date: Tue, 22 Jul 2008 14:49:47 -0400   author:   Nicholas Paldino [.NET/C# MVP]

Re: Visibility change causes menu items to scroll (bug?)   
>    The only immediate workaround I can see would be to not add the items 
> if you are not going to make them visible.  I took your example and didn't 
> add the items if they were not visible, and didn't get that effect.

I have Winforms menu system designed using Windows forms Designer in MDI 
parent form.
Some menu items may not be visible to user who logs in.

I have also command "login as different user" in this MDI parent form which 
allows other user to log in without exiting main form.
For this command I need to make some other menu items visible.

How to make items visible/invisible in this case ?

>    I would definitely register this bug on the Microsoft Connect site.

Done.
https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=357453

Andrus.
date: Wed, 23 Jul 2008 17:11:19 +0300   author:   Andrus

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us