Panels

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

    Panels

    Hi All,

    I have 2 panels that have controls on them in a win
    form. On Init of app I hide panel2 and show panel1, no
    problem. On button Click I hide panel 1 and show panel 2,
    panel 1 disappears but no panel 2 with controls showing.

    Any idea what I might be doing wrong ?

    Thanks,

    JJ
  • Chris R

    #2
    Re: Panels

    I'd almost bet the bank that your Panel2 got added to the wrong parent
    They should be both added to whatever parent control is appropriate, such
    as:

    this.Controls.A dd(this.panel2) ;
    this.Controls.A dd(this.panel1) ;

    You can check this with panel2.Parent in code or simply check in the
    InitializeCompo nent method and inspect the Add methods to see where panel2
    is being added. If it's being added to
    this.panel1.Con trols.Add(panel 2);
    then you'll never see it.

    Chris R.

    "JJ" <anonymous@disc ussions.microso ft.com> wrote in message
    news:036601c3b2 32$5285b870$a30 1280a@phx.gbl.. .[color=blue]
    > Hi All,
    >
    > I have 2 panels that have controls on them in a win
    > form. On Init of app I hide panel2 and show panel1, no
    > problem. On button Click I hide panel 1 and show panel 2,
    > panel 1 disappears but no panel 2 with controls showing.
    >
    > Any idea what I might be doing wrong ?
    >
    > Thanks,
    >
    > JJ[/color]


    Comment

    • Kenneth Baltrinic

      #3
      Re: Panels

      I concur with Chris's analysis. Moreover, once you have fixed the problem,
      be careful when using the form designer. It is really easy to resurect the
      problem again and again. Trust me. :(

      --Ken

      "Chris R" <sothryn@hotmai l.com> wrote in message
      news:OMnR2CksDH A.1680@TK2MSFTN GP12.phx.gbl...[color=blue]
      > I'd almost bet the bank that your Panel2 got added to the wrong parent
      > They should be both added to whatever parent control is appropriate, such
      > as:
      >
      > this.Controls.A dd(this.panel2) ;
      > this.Controls.A dd(this.panel1) ;
      >
      > You can check this with panel2.Parent in code or simply check in the
      > InitializeCompo nent method and inspect the Add methods to see where panel2
      > is being added. If it's being added to
      > this.panel1.Con trols.Add(panel 2);
      > then you'll never see it.
      >
      > Chris R.
      >
      > "JJ" <anonymous@disc ussions.microso ft.com> wrote in message
      > news:036601c3b2 32$5285b870$a30 1280a@phx.gbl.. .[color=green]
      > > Hi All,
      > >
      > > I have 2 panels that have controls on them in a win
      > > form. On Init of app I hide panel2 and show panel1, no
      > > problem. On button Click I hide panel 1 and show panel 2,
      > > panel 1 disappears but no panel 2 with controls showing.
      > >
      > > Any idea what I might be doing wrong ?
      > >
      > > Thanks,
      > >
      > > JJ[/color]
      >
      >[/color]


      Comment

      • JJ

        #4
        Re: Panels

        Hi All, Chris,

        I found this in the initialize component:
        this.panel1.Con trols.Add(this. panel2);
        and have commented it out. It Works!
        Also I noticed that the form designer put this in for the
        panels:

        this.panel1.Sus pendLayout();
        this.panel2.Sus pendLayout();

        What does this do?

        P.S. By the way I had commented them out and put in your
        code to get it to work right.

        Thanks,
        JJ


        [color=blue]
        >-----Original Message-----
        >I'd almost bet the bank that your Panel2 got added to[/color]
        the wrong parent[color=blue]
        >They should be both added to whatever parent control is[/color]
        appropriate, such[color=blue]
        >as:
        >
        > this.Controls.A dd(this.panel2) ;
        > this.Controls.A dd(this.panel1) ;
        >
        >You can check this with panel2.Parent in code or simply[/color]
        check in the[color=blue]
        >InitializeComp onent method and inspect the Add methods[/color]
        to see where panel2[color=blue]
        >is being added. If it's being added to
        > this.panel1.Con trols.Add(panel 2);
        >then you'll never see it.
        >
        >Chris R.
        >
        >"JJ" <anonymous@disc ussions.microso ft.com> wrote in[/color]
        message[color=blue]
        >news:036601c3b 232$5285b870$a3 01280a@phx.gbl. ..[color=green]
        >> Hi All,
        >>
        >> I have 2 panels that have controls on them in a[/color][/color]
        win[color=blue][color=green]
        >> form. On Init of app I hide panel2 and show panel1, no
        >> problem. On button Click I hide panel 1 and show panel[/color][/color]
        2,[color=blue][color=green]
        >> panel 1 disappears but no panel 2 with controls[/color][/color]
        showing.[color=blue][color=green]
        >>
        >> Any idea what I might be doing wrong ?
        >>
        >> Thanks,
        >>
        >> JJ[/color]
        >
        >
        >.
        >[/color]

        Comment

        Working...