Windows Forms: Initialize Component in VB .NET 2002

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

    Windows Forms: Initialize Component in VB .NET 2002

    Is there documentation of what we should not change in the Initialize
    Component of a Windows form?
    For example, the following code was generated by VB .NET:

    Me.AutoScaleBas eSize = New System.Drawing. Size(5, 13)
    Me.ClientSize = New System.Drawing. Size(242, 223)
    Me.Controls.Add Range(New System.Windows. Forms.Control() {Me.btnGreeting ,
    Me.txtName, Me.lblInstructi on})
    Me.Menu = Me.OptionMenu
    Me.Name = "frmHello"
    Me.Text = "Hello"
    Me.ResumeLayout (False)

    I then changed the code to:

    With Me
    .AutoScaleBaseS ize = New System.Drawing. Size(5, 13)
    .ClientSize = New System.Drawing. Size(242, 223)
    .Controls.AddRa nge(New System.Windows. Forms.Control() _
    {.btnGreeting, .txtName, .lblInstruction })
    .Menu = .OptionMenu
    .Name = "frmHello"
    .Text = "Hello"
    .ResumeLayout(F alse)
    End With

    This change caused the controls to vanish in designer view, but the code
    still ran correctly.

    Where can I find more info on what we can do with code in the Initialize
    Component?
    --
    http://www.standards.com/; See Howard Kaikow's web site.



  • Armin Zingler

    #2
    Re: Windows Forms: Initialize Component in VB .NET 2002

    "Howard Kaikow" <kaikow@standar ds.com> schrieb[color=blue]
    >
    > Where can I find more info on what we can do with code in the
    > Initialize Component?[/color]

    You can do nothing in InitializeCompo nent. See the comment above the
    procedure. It says: Do NOT use the code editor for modifications, use the
    Form designer instead.


    --
    Armin

    Comment

    • Howard Kaikow

      #3
      Re: Windows Forms: Initialize Component in VB .NET 2002

      I'm not modifying, just making the code more efficient.

      --
      http://www.standards.com/; See Howard Kaikow's web site.
      "Armin Zingler" <az.nospam@free net.de> wrote in message
      news:eSx4AvYdDH A.736@TK2MSFTNG P09.phx.gbl...[color=blue]
      > "Howard Kaikow" <kaikow@standar ds.com> schrieb[color=green]
      > >
      > > Where can I find more info on what we can do with code in the
      > > Initialize Component?[/color]
      >
      > You can do nothing in InitializeCompo nent. See the comment above the
      > procedure. It says: Do NOT use the code editor for modifications, use the
      > Form designer instead.
      >
      >
      > --
      > Armin
      >[/color]


      Comment

      • Herfried K. Wagner [MVP]

        #4
        Re: Windows Forms: Initialize Component in VB .NET 2002

        Hello,

        "Howard Kaikow" <kaikow@standar ds.com> schrieb:[color=blue]
        > I'm not modifying, just making the code more efficient.[/color]

        The designer seems to have problems if you use different rules for
        formatting/writing the sourcecode. Some changes can be done by hand
        (removing assignment of values to properties and so on), but always make
        a copy before modifying.

        --
        Herfried K. Wagner
        MVP · VB Classic, VB .NET
        Die Website von H. Wagner zu .NET, Visual Basic .NET und Classic Visual Basic.



        Comment

        • Armin Zingler

          #5
          Re: Windows Forms: Initialize Component in VB .NET 2002

          "Howard Kaikow" <kaikow@standar ds.com> schrieb[color=blue]
          > I'm not modifying, just making the code more efficient.[/color]

          Whenever you are making the code more efficient, you are modifying the code.


          --
          Armin

          Comment

          • Fergus Cooney

            #6
            Re: Windows Forms: Initialize Component in VB .NET 2002

            Hi Howard,

            I've not tested it but if the compiler's any good it will produce code
            that does effectively what your With statement does.

            There are a few modifications that you can get away with in this area.
            Anything that makes it lose sync with the Form's resx file will cause
            problems. In the worst case it will screw up the resx file completely and
            you'll have to repopulate the Form from scratch.

            I share your desire to tinker in that zone - it looks so messy. But that's
            one use of Regions - to sweep mess (other people's, of course, lol) under the
            carpet.

            Regards,
            Fergus


            Comment

            • Herfried K. Wagner [MVP]

              #7
              Re: Windows Forms: Initialize Component in VB .NET 2002

              Hello,

              "Fergus Cooney" <filter-1@tesco.net> schrieb:[color=blue]
              > In the worst case it will screw up the resx file completely and
              > you'll have to repopulate the Form from scratch.[/color]

              Or use a backup...

              ;-)

              --
              Herfried K. Wagner
              MVP · VB Classic, VB .NET
              Die Website von H. Wagner zu .NET, Visual Basic .NET und Classic Visual Basic.



              Comment

              • Fergus Cooney

                #8
                Re: Windows Forms: Initialize Component in VB .NET 2002

                Hi Herfried,

                || Or use a backup...

                What's a backup?

                Regards,
                Fergus


                Comment

                • Cor

                  #9
                  Re: Windows Forms: Initialize Component in VB .NET 2002

                  Hi Fergus,[color=blue]
                  > What's a backup?
                  >[/color]
                  This is a news group about Vb.net.
                  For that question are other newsgroups .

                  :-)
                  Cor


                  Comment

                  • Fergus Cooney

                    #10
                    Re: Windows Forms: Initialize Component in VB .NET 2002

                    Hi Cor,

                    Grrr. Any more talk like that and you'll get <my> back up!!

                    Lol. ;-D

                    Regards,
                    Fergus

                    [Does that English make sense? It's funning and punning. :-)]


                    Comment

                    • Cor

                      #11
                      Re: Windows Forms: Initialize Component in VB .NET 2002

                      Fergus,
                      Yes that what I mean that kind of back up newsgroup, but not yours, yours is
                      a VB.net language group.
                      :-)
                      Cor


                      Comment

                      • Fergus Cooney

                        #12
                        Re: Windows Forms: Initialize Component in VB .NET 2002

                        Hi Cor,

                        I thought I might have to explain. :-)

                        When you "get someone's back up", it means to make them angry. In the
                        sense of a hissing cat when it arches its back and fluffs up its fur. So I was
                        pretending to be angry so that I could use "backup" in that way.

                        Regards,
                        Fergus


                        Comment

                        • Herfried K. Wagner [MVP]

                          #13
                          Re: Windows Forms: Initialize Component in VB .NET 2002

                          Hello,

                          "Fergus Cooney" <filter-1@tesco.net> schrieb:[color=blue]
                          > || Or use a backup...
                          >
                          > What's a backup?[/color]

                          A copy of the project used to restore it if the original project is
                          damaged/lost.

                          ;-)

                          --
                          Herfried K. Wagner
                          MVP · VB Classic, VB .NET
                          Die Website von H. Wagner zu .NET, Visual Basic .NET und Classic Visual Basic.



                          Comment

                          • Cor

                            #14
                            Re: Windows Forms: Initialize Component in VB .NET 2002

                            Fergus,
                            Exactly the same as in Dutch, in Dutch it has to a literary meaning, but
                            that is probably in Cockney not the same?
                            :-)
                            Cor


                            Comment

                            • Herfried K. Wagner [MVP]

                              #15
                              Re: Windows Forms: Initialize Component in VB .NET 2002

                              Hello,

                              "Cor" <non@non.com> schrieb:[color=blue][color=green]
                              > > What's a backup?[/color]
                              >
                              > This is a news group about Vb.net.
                              > For that question are other newsgroups .[/color]

                              "How to make a backup of a project using VB.NET?" -- the question is
                              related to VB.NET programming.

                              ;-)

                              --
                              Herfried K. Wagner
                              MVP · VB Classic, VB .NET
                              Die Website von H. Wagner zu .NET, Visual Basic .NET und Classic Visual Basic.



                              Comment

                              Working...