Question Menustrip disapers when form is resized

tellblom

Member
Joined
Jul 3, 2022
Messages
16
Programming Experience
10+
Hi, I have a menuStrip1 that is has setting DOCK =TOP.
The Form has MainMenuStrip set to this menuStrip1.
When the form is resized (read smaller) the menu disappears together with the top content of the form.

I have tried this setting with no result, it still disapers:
menuStrip1.AutoSize = true;
menuStrip1.RenderMode = ToolStripRenderMode.Professional;
menuStrip1.GripStyle = ToolStripGripStyle.Visible;
menuStrip1.CanOverflow = true;

What have I done wrong?
 
What is the value of menuStrip1.MinimumSize?
 
Can you post the contents of the designer code file, so we can try the same configuration?

Is it this you mean?
C#:
            //
            // menuStrip1
            //
            menuStrip1.Items.AddRange(new ToolStripItem[] { fileToolStripMenuItem, adminToolStripMenuItem, languageIdiomaToolStripMenuItem, helpToolStripMenuItem });
            menuStrip1.Location = new Point(0, 0);
            menuStrip1.Name = "menuStrip1";
            menuStrip1.Size = new Size(2148, 24);
            menuStrip1.TabIndex = 1;
            menuStrip1.Text = "menuStrip1";
 
Yes, that's part of it. We'll likely need the entire file.
 
Is it this you mean?
C#:
            //
            // menuStrip1
            //
            menuStrip1.Items.AddRange(new ToolStripItem[] { fileToolStripMenuItem, adminToolStripMenuItem, languageIdiomaToolStripMenuItem, helpToolStripMenuItem });
            menuStrip1.Location = new Point(0, 0);
            menuStrip1.Name = "menuStrip1";
            menuStrip1.Size = new Size(2148, 24);
            menuStrip1.TabIndex = 1;
            menuStrip1.Text = "menuStrip1";

The designer code file is what generates what you see in the designer. If you provide the contents of that file, we can paste it into a designer code file in a test project of our own and the designer will show the same thing that you're seeing. We can then run that project and see whether we get the same behaviour as you do. If we do, we can diagnose it much more easily when we can see it right in front of us. If we can't, we need to look for what else might be different in your project compared to ours.
 
The designer code file is what generates what you see in the designer. If you provide the contents of that file, we can paste it into a designer code file in a test project of our own and the designer will show the same thing that you're seeing. We can then run that project and see whether we get the same behaviour as you do. If we do, we can diagnose it much more easily when we can see it right in front of us. If we can't, we need to look for what else might be different in your project compared to ours.
here is the complete file, added .txt so I could attach it
 

Attachments

  • Form1.Designer.cs.txt
    69.3 KB · Views: 11
It is due to AutoScroll and which control that has focus, when resizing that control is kept in scroll view.

If you always want top-left corner of form visible when resizing you could handle Resize event and set AutoScrollPosition = Point.Empty.
 
here is the complete file, added .txt so I could attach it

Don't attach it. Just copy the code and post it directly, just like you did before. That way, we can just copy and paste directly from this thread instead of having to download a file and then get the code out ourselves.
 
It is due to AutoScroll and which control that has focus, when resizing that control is kept in scroll view.

If you always want top-left corner of form visible when resizing you could handle Resize event and set AutoScrollPosition = Point.Empty.

An alternative may be to add just the menu and a Panel to the form, then add all the other controls to the Panel. You can then make the contents of the Panel auto-scroll so that will not affect the menu.
 
Back
Top Bottom