Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Must be very simple but I can't figure it out.

 

I have a panel with a form loaded.

I want to get rid of the form within that panel, when I push

on a button outside that panel.

 

Thought I use a Clear function, like panel1.clear

but that ain't there...

 

Is there a easy way to clear a panel?

Posted

I am a confused about what it is you are doing. Do you have 2 forms, Form A has a panel and within that panel FormB is shown?

 

If this is the case, let me know as I am would like to know how it is done.

Posted

That's correct :-)

And I can't do a form.dispose within that panel.

so I need something to clear the panel, cause the form name etc.

it not recognized elsewhere in my code.

 

 

And this is how you create a form within a panel on another form..

 

I have a mainform with 3 panels. ala Outlook Style.

 

panel 40 is the right panel for me, and thats where everything

is happening.

I have a button on the left site, and this is what's underneath that button.

 

 

Dim addressbook As Form

addressbook = New Frmaddressbook

addressbook.TopLevel = False

addressbook.Dock = DockStyle.Fill

addressbook.Parent = Panel40

addressbook.Show()

 

Good luck

Posted

I found how to do it on another website.

 

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim frm As New Form2()

 

frm.TopLevel = False

 

Panel1.Controls.Add(frm)

 

frm.Show()

 

End Sub

 

 

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

 

Panel1.Controls.Clear()

 

End Sub

 

 

 

This works for me, but only problem I have is on resize, the form on the panel will not move with the panel size. I have tried anchoring and docking, but none will work

Posted

Umm......I havn't ventured into overrides yet. Will this override be in the main form or in the form being displayed in the panel?

 

Is it possible to give me what should be in the sub to perform this?

 

Thanks

Posted

Whichever form resizes first. After one resizes you can set the size of the other, if you want.

 

I only know C syntax not VB, you will have to translate.

 

protected override void OnResize(EventArgs e)

{

base.OnResize(e);

**Your code here**

**maybe something like**

form2.Size= form1.Size;

}

 

You wouldn't even have to use that. It is just less writing than hooking up an event (OnResize event) and in my opinion, faster code.

C#
Posted

I was pulling my hair out for ages trying to get it to work. I had my sub forms Window State set to maximized (thinking it would fill the entire panel) and it wouldn't work. I changed them to normal and it goes fine.

 

Sneaky little things........

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...