search
Japanese Chinese Nederlands Espanol Italiano Deutsch Francais Twitter Rss Feeds
MicrosoftArticlesForumsFAQs
C# .NET
VB.NET
Visual Studio .NET
ADO.NET
Xml / Xslt
VB 6.0
.NET CF
GDI+
LINQ
Deployment
Security
FoxPro
Silverlight / WPF
Entity Framework
RIA Services

Web ProgrammingArticlesForumsFAQs
JavaScript
ASP
ASP.NET
Web Services

Non-MicrosoftArticlesForumsFAQs
NHibernate
Perl
PHP
Ruby
Java
Linux / Unix
Apple
Open Source

DatabasesArticlesForumsFAQs
SQL Server
Access
Oracle
MySQL
Other Databases

OfficeArticlesForumsFAQs
Excel
Word
Powerpoint
Outlook
Publisher
Money

Operating SystemsArticlesForumsFAQs
Windows 7
Windows Server
Windows Vista
Windows XP
Windows Update
MAC
Linux / UNIX

Server PlatformsArticlesForumsFAQs
BizTalk
Site Server
Exhange Server
IIS

Graphic DesignArticlesForumsFAQs
Macromedia Flash
Adobe PhotoShop
Expression Blend
Expression Design
Expression Web

OtherArticlesForumsFAQs
Subversion / CVS
Ask Dr. Dotnetsky
Active Directory
Networking
Uninstall Virus
Job Openings
Product Reviews
Search Engines
Resumes

 

.NET Windows Forms - Can't Change Docking Order


By Robbe Morris
Printer Friendly Version
View My Articles
26 Views
    

Having trouble adjusting the docking order of your controls in a .net windows forms application? Simply undocking and then redocking the controls in the order you want hardly ever works.


The only way I've found to consistantly get this to work is to undock all of the applicable controls from their container.  This could be all controls on a form or all controls on a given panel (or some other container control).

Then, dock the first control.  For all subsequent controls that need to be redocked, use CTRL-X to temporarily delete them from Visual Studio and then CTRL-C to paste them back in again.  Then, redock that control.  You'll have to do this for each control.  All of the control names and attributes will remain the same.

However, you will need to recreate the event wireups.  For most controls, this is as simple as double clicking the control or going to the events section of the property grid.

After you have done this, close the designer for the form and open the .cs code file.  If you have found that Visual Studio created new event place holders like this:

old

private void mybutton_onclick

new

private void mybutton_onclick_1

Remove the new instance and try to compile your app.  Visual Studio
should fail to compile and give you all the places you need to tweak in the designer.cs file.

What is important to note is that if you attempt to fix the event place holders while the form is still up in design mode, Visual Studio will remove all of the newly created placeholders and you'll be back to square one for recreating your event placeholders.


Biography - Robbe Morris
Robbe has been a Microsoft MVP in C# since 2004. He is also the co-founder of EggHeadCafe.com which provides .NET articles, book reviews, software reviews, and software download and purchase advice.

button
Article Discussion: .NET Windows Forms - Can't Change Docking Order
Robbe Morris posted at Thursday, October 12, 2006 3:41 PM
Original Article