Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Visual Studio 2008 Designer ToolStrip changes locations of toolstrips after recompiling

Posted on 2010-11-30
7
Medium Priority
?
1,051 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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
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 2000 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 2000 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

Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

Question has a verified solution.

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

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
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 …
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

783 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