Adding ToolBar to an existing form...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andy Bates

    Adding ToolBar to an existing form...

    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



  • Tom

    #2
    Re: Adding ToolBar to an existing form...

    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.



    "Andy Bates" <Andy.Bates@Ult imateSoftwareSo lutions.com> wrote in message
    news:%23Ez4o1li DHA.1872@TK2MSF TNGP10.phx.gbl. ..[color=blue]
    > I have hopefully a simple problem in C#.
    >
    > I designed a form with a listview on left, vert splitter against that,[/color]
    then[color=blue]
    > the remainder of the form from top to bottom: a listview, horiz splitter[/color]
    and[color=blue]
    > 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
    >
    >
    >[/color]


    Comment

    • Tom

      #3
      Re: Adding ToolBar to an existing form...

      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.



      "Andy Bates" <Andy.Bates@Ult imateSoftwareSo lutions.com> wrote in message
      news:%23Ez4o1li DHA.1872@TK2MSF TNGP10.phx.gbl. ..[color=blue]
      > I have hopefully a simple problem in C#.
      >
      > I designed a form with a listview on left, vert splitter against that,[/color]
      then[color=blue]
      > the remainder of the form from top to bottom: a listview, horiz splitter[/color]
      and[color=blue]
      > 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
      >
      >
      >[/color]


      Comment

      • Jeffrey Tan[MSFT]

        #4
        RE: Adding ToolBar to an existing form...


        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.toolBa r1);" 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" <Andy.Bates@Ult imateSoftwareSo lutions.com>
        | 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: <#Ez4o1liDHA.18 72@TK2MSFTNGP10 .phx.gbl>
        | Newsgroups: microsoft.publi c.dotnet.langua ges.csharp
        | NNTP-Posting-Host: cpc3-farn1-6-0-cust68.glfd.cab le.ntl.com 81.105.30.68
        | Path: cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!TK2 MSFTNGP10.phx.g bl
        | Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.csharp:1889 34
        | X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.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
        |
        |
        |
        |

        Comment

        • Jeffrey Tan[MSFT]

          #5
          RE: Adding ToolBar to an existing form...


          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.toolBa r1);" 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" <Andy.Bates@Ult imateSoftwareSo lutions.com>
          | 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: <#Ez4o1liDHA.18 72@TK2MSFTNGP10 .phx.gbl>
          | Newsgroups: microsoft.publi c.dotnet.langua ges.csharp
          | NNTP-Posting-Host: cpc3-farn1-6-0-cust68.glfd.cab le.ntl.com 81.105.30.68
          | Path: cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!TK2 MSFTNGP10.phx.g bl
          | Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.csharp:1889 34
          | X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.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
          |
          |
          |
          |

          Comment

          • Andy Bates

            #6
            Re: Adding ToolBar to an existing form...

            Tom/Jeffrey -

            Thanks both solutions seem to work.

            Jeffrey - With regards to your suggestion, the fix is obviously applied to
            the InitializeCompo nent 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

            "Jeffrey Tan[MSFT]" <v-jetan@online.mi crosoft.com> wrote in message
            news:u7TGHp7iDH A.1548@cpmsftng xa06.phx.gbl...[color=blue]
            >
            > 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[/color]
            splitter.[color=blue]
            > 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.toolBa r1);" 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" <Andy.Bates@Ult imateSoftwareSo lutions.com>
            > | 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: <#Ez4o1liDHA.18 72@TK2MSFTNGP10 .phx.gbl>
            > | Newsgroups: microsoft.publi c.dotnet.langua ges.csharp
            > | NNTP-Posting-Host: cpc3-farn1-6-0-cust68.glfd.cab le.ntl.com 81.105.30.68
            > | Path: cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!TK2 MSFTNGP10.phx.g bl
            > | Xref: cpmsftngxa06.ph x.gbl[/color]
            microsoft.publi c.dotnet.langua ges.csharp:1889 34[color=blue]
            > | X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.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[/color]
            I[color=blue]
            > | added this, it didn't appear at the top as expected, but at the top of[/color]
            the[color=blue]
            > | 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[/color]
            easily?[color=blue]
            > |
            > | TIA
            > |
            > | - Andy
            > |
            > |
            > |
            > |
            >[/color]


            Comment

            • Andy Bates

              #7
              Re: Adding ToolBar to an existing form...

              Tom/Jeffrey -

              Thanks both solutions seem to work.

              Jeffrey - With regards to your suggestion, the fix is obviously applied to
              the InitializeCompo nent 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

              "Jeffrey Tan[MSFT]" <v-jetan@online.mi crosoft.com> wrote in message
              news:u7TGHp7iDH A.1548@cpmsftng xa06.phx.gbl...[color=blue]
              >
              > 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[/color]
              splitter.[color=blue]
              > 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.toolBa r1);" 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" <Andy.Bates@Ult imateSoftwareSo lutions.com>
              > | 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: <#Ez4o1liDHA.18 72@TK2MSFTNGP10 .phx.gbl>
              > | Newsgroups: microsoft.publi c.dotnet.langua ges.csharp
              > | NNTP-Posting-Host: cpc3-farn1-6-0-cust68.glfd.cab le.ntl.com 81.105.30.68
              > | Path: cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!TK2 MSFTNGP10.phx.g bl
              > | Xref: cpmsftngxa06.ph x.gbl[/color]
              microsoft.publi c.dotnet.langua ges.csharp:1889 34[color=blue]
              > | X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.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[/color]
              I[color=blue]
              > | added this, it didn't appear at the top as expected, but at the top of[/color]
              the[color=blue]
              > | 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[/color]
              easily?[color=blue]
              > |
              > | TIA
              > |
              > | - Andy
              > |
              > |
              > |
              > |
              >[/color]


              Comment

              • Jeffrey Tan[MSFT]

                #8
                Re: Adding ToolBar to an existing form...


                Hi Andy,

                I think your understanding of out of bounds to change must be the comment
                of InitializeCompo nent 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.

                InitializeCompo nent 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" <Andy.Bates@Ult imateSoftwareSo lutions.com>
                | References: <#Ez4o1liDHA.18 72@TK2MSFTNGP10 .phx.gbl>
                <u7TGHp7iDHA.15 48@cpmsftngxa06 .phx.gbl>
                | 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: <#E3ksx8iDHA.17 84@tk2msftngp13 .phx.gbl>
                | Newsgroups: microsoft.publi c.dotnet.langua ges.csharp
                | NNTP-Posting-Host: cpc3-farn1-6-0-cust68.glfd.cab le.ntl.com 81.105.30.68
                | Path: cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!tk2 msftngp13.phx.g bl
                | Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.csharp:1891 47
                | X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.csharp
                |
                | Tom/Jeffrey -
                |
                | Thanks both solutions seem to work.
                |
                | Jeffrey - With regards to your suggestion, the fix is obviously applied to
                | the InitializeCompo nent 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
                |
                | "Jeffrey Tan[MSFT]" <v-jetan@online.mi crosoft.com> wrote in message
                | news:u7TGHp7iDH A.1548@cpmsftng xa06.phx.gbl...
                | >
                | > 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.toolBa r1);" 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" <Andy.Bates@Ult imateSoftwareSo lutions.com>
                | > | 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: <#Ez4o1liDHA.18 72@TK2MSFTNGP10 .phx.gbl>
                | > | Newsgroups: microsoft.publi c.dotnet.langua ges.csharp
                | > | NNTP-Posting-Host: cpc3-farn1-6-0-cust68.glfd.cab le.ntl.com
                81.105.30.68
                | > | Path: cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!TK2 MSFTNGP10.phx.g bl
                | > | Xref: cpmsftngxa06.ph x.gbl
                | microsoft.publi c.dotnet.langua ges.csharp:1889 34
                | > | X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.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
                | > |
                | > |
                | > |
                | > |
                | >
                |
                |
                |

                Comment

                Working...