Solved

Visual Studio 2008 Designer ToolStrip changes locations of toolstrips after recompiling

Posted on 2010-11-30
7
1,033 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_
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
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…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

710 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