Position Control when Created dynamically

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

    Position Control when Created dynamically

    I have a menu item that creates a new command button.
    Each time I create a new command button I need to position it to the left of
    the last created button.
    In VB6 I could create a control array, look at the UBound of the array (Last
    control Created) and find the
    position of the last created control in order to place any new controls next
    to it.
    Creating controls in DotNet is different. I can create the controls
    dynamically but have no
    way of getting the co-ordinates of the previously created control since
    there is no index property.

    -Lou


  • Cor Ligthert [MVP]

    #2
    Re: Position Control when Created dynamically

    Lou,

    Of course is there an index property.
    The first in an array is 0.

    So the previous control is when it is not zero this index -1

    Cor



    Comment

    • RobinS

      #3
      Re: Position Control when Created dynamically

      Cor, you're talking about the TabIndex, right?

      Robin S.
      ------------------------------
      "Cor Ligthert [MVP]" <notmyfirstname @planet.nlwrote in message
      news:e$RMQN0SHH A.1000@TK2MSFTN GP05.phx.gbl...
      Lou,
      >
      Of course is there an index property.
      The first in an array is 0.
      >
      So the previous control is when it is not zero this index -1
      >
      Cor
      >
      >
      >

      Comment

      • Cor Ligthert [MVP]

        #4
        Re: Position Control when Created dynamically

        Cor, you're talking about the TabIndex, right?
        no .

        dim mycontrolarray( ) as control = {Button1, TextBox2, TextBox4, Button2}

        The indexes are in that case 0, 1,2,3

        Cor



        Comment

        • Lou

          #5
          Re: Position Control when Created dynamically

          There is no index property of a button
          I thought you could not have an array of controls in DotNet.


          "Cor Ligthert [MVP]" <notmyfirstname @planet.nlwrote in message
          news:O6fnIf0SHH A.3316@TK2MSFTN GP02.phx.gbl...
          >
          >Cor, you're talking about the TabIndex, right?
          >
          no .
          >
          dim mycontrolarray( ) as control = {Button1, TextBox2, TextBox4, Button2}
          >
          The indexes are in that case 0, 1,2,3
          >
          Cor
          >
          >
          >

          Comment

          • rowe_newsgroups

            #6
            Re: Position Control when Created dynamically

            On Feb 8, 7:42 am, "Lou" <lou.gar...@com cast.netwrote:
            There is no index property of a button
            I thought you could not have an array of controls in DotNet.
            >
            "Cor Ligthert [MVP]" <notmyfirstn... @planet.nlwrote in messagenews:O6f nIf0SHHA.3316@T K2MSFTNGP02.phx .gbl...
            >
            >
            >
            Cor, you're talking about the TabIndex, right?
            >
            no .
            >
            dim mycontrolarray( ) as control = {Button1, TextBox2, TextBox4, Button2}
            >
            The indexes are in that case 0, 1,2,3
            >
            Cor
            He's talking about the index of an array that contains the control,
            not the old VB6 index property.

            Thanks,

            Seth Rowe

            Comment

            • RobinS

              #7
              Re: Position Control when Created dynamically

              Yeah, that's what I suspected, but it wasn't clear. The OP is thinking
              about control arrays as they existed in VB6.

              Robin S.
              -------------------------------------
              "Cor Ligthert [MVP]" <notmyfirstname @planet.nlwrote in message
              news:O6fnIf0SHH A.3316@TK2MSFTN GP02.phx.gbl...
              >
              >Cor, you're talking about the TabIndex, right?
              >
              no .
              >
              dim mycontrolarray( ) as control = {Button1, TextBox2, TextBox4, Button2}
              >
              The indexes are in that case 0, 1,2,3
              >
              Cor
              >
              >
              >

              Comment

              • RobinS

                #8
                Re: Position Control when Created dynamically

                You can put them in an array yourself in the code behind the form, as Cor
                has done in his example.

                Robin S.
                ------------------------------------
                "Lou" <lou.garvin@com cast.netwrote in message
                news:upjGf63SHH A.4252@TK2MSFTN GP05.phx.gbl...
                There is no index property of a button
                I thought you could not have an array of controls in DotNet.
                >
                >
                "Cor Ligthert [MVP]" <notmyfirstname @planet.nlwrote in message
                news:O6fnIf0SHH A.3316@TK2MSFTN GP02.phx.gbl...
                >>
                >>Cor, you're talking about the TabIndex, right?
                >>
                >no .
                >>
                >dim mycontrolarray( ) as control = {Button1, TextBox2, TextBox4, Button2}
                >>
                >The indexes are in that case 0, 1,2,3
                >>
                >Cor
                >>
                >>
                >>
                >
                >

                Comment

                Working...