Solved

Visual Studio 2008 Designer ToolStrip changes locations of toolstrips after recompiling

Posted on 2010-11-30
7
1,027 Views
Last Modified: 2012-05-10
Hi,

I have a form application written in Visual Studio 2008. It has a toolstripcontainer with 3 ToolStrips on it.  The locations for the toolstrips are set in InitialComponent() like so:
this.ToolStrip1.Location = new System.Drawing.Point(56, 0);
this.ToolStrip2.Location = new System.Drawing.Point(263, 0);
this.ToolStrip3.Location = new System.Drawing.Point(578, 0);

However, after viewing the designer, these values are automatically being reset to these default values:
this.ToolStrip1.Location = new System.Drawing.Point(40, 50);
this.ToolStrip2.Location = new System.Drawing.Point(11, 25);
this.ToolStrip3.Location = new System.Drawing.Point(3, 0);

What's going on here? Does this happen in VS 2010 as well?

Regards,


Wade
0
Comment
Question by:_Wade_
  • 3
  • 2
  • 2
7 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 34242722
Do you have any anchoring or docking setup?
0
 

Author Comment

by:_Wade_
ID: 34243780
No
0
 

Author Comment

by:_Wade_
ID: 34243796
So you think it's due to anchoring?  I believe I tried this one time and it didn't work.  What I'm doing is I'm manually positioning them in the designer where I want them. I was thinking that anchoring or docking would affect this.
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 83

Expert Comment

by:CodeCruiser
ID: 34246397
Do you open the form in maximized size? Many things can affect this including anchoring.
0
 
LVL 3

Accepted Solution

by:
pnedic earned 500 total points
ID: 34247214
I have faced the same situation on some other controls. I did not find the reason, as well as I did not find the real solution (beside suggested solution bellow). I had it in VS2003 and C#.

Visual Studio obviously has this bug which is not affected on some other controls.

I think that some of the properties of the parent form causes toolstrip re-positioning such as: AutoSize(Mode), Dock etc.

If you placed tollstrips 2 and 3 using copy-paste toolstrip 1, I suggest to delete 2 and 3 and place them manually from toolbox. Also check Dock properties for them.

If nothing helps, my simple suggestion is to copy lines with your toolstrip positions just bellow existing - and comment them. On this way, whenever designer make it's own repositions, you have original code to return back to your desired positions. Just copy-paste.
0
 

Author Comment

by:_Wade_
ID: 34252687
All of the doc properties for the toolstrips are set to "none"
0
 
LVL 3

Assisted Solution

by:pnedic
pnedic earned 500 total points
ID: 34255501
Have you checked FORM properties (on which you've placed toolstrips) ?

I have just inserted 3 toolstrips on form without your problem.

For all toolstrips set following properties:
AutoSize = False
Anchor = Top, Left
Dock = None (you already have this)
Locked = True

finally this is the list of tollstrip1 properties from InitializeComponent

Me.ToolStrip1.AutoSize = False
Me.ToolStrip1.Dock = System.Windows.Forms.DockStyle.None
Me.ToolStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ToolStripButton1})
Me.ToolStrip1.Location = New System.Drawing.Point(0, 0)
Me.ToolStrip1.Name = "ToolStrip1"
Me.ToolStrip1.Size = New System.Drawing.Size(75, 25)
Me.ToolStrip1.TabIndex = 70
Me.ToolStrip1.Text = "ToolStrip1"
Me.ToolStripButton1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
Me.ToolStripButton1.Image = CType(resources.GetObject("ToolStripButton1.Image"), System.Drawing.Image)
Me.ToolStripButton1.ImageTransparentColor = System.Drawing.Color.Magenta
Me.ToolStripButton1.Name = "ToolStripButton1"
Me.ToolStripButton1.Size = New System.Drawing.Size(23, 22)
Me.ToolStripButton1.Text = "ToolStripButton1"

For other two toolstrips just change name and location as (for example)
Me.ToolStrip2.Location = New System.Drawing.Point(25, 0)
Me.ToolStrip3.Location = New System.Drawing.Point(50, 0)
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
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 Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

773 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