Adding ToolBar to an existing form...

A

Andy Bates

I have hopefully a simple problem in C#.

I designed a form with a listview on left, vert splitter against that, then
the remainder of the form from top to bottom: a listview, horiz splitter and
tab control (very similar to outlook express).

I then started coding and realised that I needed to add a ToolBar. When I
added this, it didn't appear at the top as expected, but at the top of the
tab control and I couldn't get it to appear where I wanted it to!

Can anybody explain how to get the toolbar to the top of the form easily?

TIA

- Andy
 
T

Tom

Maybe you don't have the Z-order the way you want it. Try right clicking on
the Toolbar and selecting the "Send to Back" menu item. If that doesn't
take the toolbar to the top of the form, you probably sited it somewhere
other than on the form. I'd undock my other controls, move them down a bit,
then drag and drop (not cut and paste, or you may lose the toolbar contents)
the toolbar onto the main form.

Hope this helps.

Tom Clement
Apptero, Inc.
 
J

Jeffrey Tan[MSFT]

Hi Andy,

The late added control's Dock property will based on the early added
control, so when you add the toolbar control, it will base on the splitter.
In the code behind, this late-early base way was defined by the order that
the control reference was added into the form's Controls collection.

To get what you want, you need just move the statement
"this.Controls.Add(this.toolBar1);" below all other controls' add
statement, then the toolbar's Dock will based on the form's edge.

Hope this helps,
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| From: "Andy Bates" <[email protected]>
| Subject: Adding ToolBar to an existing form...
| Date: Sat, 4 Oct 2003 10:53:38 +0100
| Lines: 18
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <#[email protected]>
| Newsgroups: microsoft.public.dotnet.languages.csharp
| NNTP-Posting-Host: cpc3-farn1-6-0-cust68.glfd.cable.ntl.com 81.105.30.68
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:188934
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| I have hopefully a simple problem in C#.
|
| I designed a form with a listview on left, vert splitter against that,
then
| the remainder of the form from top to bottom: a listview, horiz splitter
and
| tab control (very similar to outlook express).
|
| I then started coding and realised that I needed to add a ToolBar. When I
| added this, it didn't appear at the top as expected, but at the top of the
| tab control and I couldn't get it to appear where I wanted it to!
|
| Can anybody explain how to get the toolbar to the top of the form easily?
|
| TIA
|
| - Andy
|
|
|
|
 
A

Andy Bates

Tom/Jeffrey -

Thanks both solutions seem to work.

Jeffrey - With regards to your suggestion, the fix is obviously applied to
the InitializeComponent method, which as I understood it was out of bounds
for changes, but it appears that this change has been retained; what changes
get kept and what get lost?!?

Regards

- Andy
 
J

Jeffrey Tan[MSFT]

Hi Andy,

I think your understanding of out of bounds to change must be the comment
of InitializeComponent method:
" Required method for Designer support - do not modify
the contents of this method with the code editor."

This comment means that Microsoft suggests that you do not modify this code
section, but any changes to it will still take effect.

InitializeComponent method is created by the VS.NET designer and it is
associated with(reflect) the designer, so Microsoft suggests that you
change your control in the designer not in the code.(It is more safe and
convient at most time.)

For your problem, you also can get it down in the designer, but I think it
is more convinent to change the order of 2 sentences.

Does this answer your question?
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| From: "Andy Bates" <[email protected]>
| References: <#[email protected]>
<[email protected]>
| Subject: Re: Adding ToolBar to an existing form...
| Date: Mon, 6 Oct 2003 06:40:55 +0100
| Lines: 79
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <#[email protected]>
| Newsgroups: microsoft.public.dotnet.languages.csharp
| NNTP-Posting-Host: cpc3-farn1-6-0-cust68.glfd.cable.ntl.com 81.105.30.68
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:189147
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| Tom/Jeffrey -
|
| Thanks both solutions seem to work.
|
| Jeffrey - With regards to your suggestion, the fix is obviously applied to
| the InitializeComponent method, which as I understood it was out of bounds
| for changes, but it appears that this change has been retained; what
changes
| get kept and what get lost?!?
|
| Regards
|
| - Andy
|
| | >
| > Hi Andy,
| >
| > The late added control's Dock property will based on the early added
| > control, so when you add the toolbar control, it will base on the
| splitter.
| > In the code behind, this late-early base way was defined by the order
that
| > the control reference was added into the form's Controls collection.
| >
| > To get what you want, you need just move the statement
| > "this.Controls.Add(this.toolBar1);" below all other controls' add
| > statement, then the toolbar's Dock will based on the form's edge.
| >
| > Hope this helps,
| > Best regards,
| > Jeffrey Tan
| > Microsoft Online Partner Support
| > Get Secure! - www.microsoft.com/security
| > This posting is provided "as is" with no warranties and confers no
rights.
| >
| > --------------------
| > | From: "Andy Bates" <[email protected]>
| > | Subject: Adding ToolBar to an existing form...
| > | Date: Sat, 4 Oct 2003 10:53:38 +0100
| > | Lines: 18
| > | X-Priority: 3
| > | X-MSMail-Priority: Normal
| > | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| > | Message-ID: <#[email protected]>
| > | Newsgroups: microsoft.public.dotnet.languages.csharp
| > | NNTP-Posting-Host: cpc3-farn1-6-0-cust68.glfd.cable.ntl.com
81.105.30.68
| > | Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
| > | Xref: cpmsftngxa06.phx.gbl
| microsoft.public.dotnet.languages.csharp:188934
| > | X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
| > |
| > | I have hopefully a simple problem in C#.
| > |
| > | I designed a form with a listview on left, vert splitter against that,
| > then
| > | the remainder of the form from top to bottom: a listview, horiz
splitter
| > and
| > | tab control (very similar to outlook express).
| > |
| > | I then started coding and realised that I needed to add a ToolBar.
When
| I
| > | added this, it didn't appear at the top as expected, but at the top of
| the
| > | tab control and I couldn't get it to appear where I wanted it to!
| > |
| > | Can anybody explain how to get the toolbar to the top of the form
| easily?
| > |
| > | TIA
| > |
| > | - Andy
| > |
| > |
| > |
| > |
| >
|
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top