Solved

Visual Studio 2008 Designer ToolStrip changes locations of toolstrips after recompiling

Posted on 2010-11-30
7
1,019 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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

705 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

20 Experts available now in Live!

Get 1:1 Help Now