Solved

Visual Studio 2008 Designer ToolStrip changes locations of toolstrips after recompiling

Posted on 2010-11-30
7
1,025 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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

DevOps Toolchain Recommendations

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

Question has a verified solution.

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

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 article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…

929 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now