473,394 Members | 1,879 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Problems removing text

I have a program (code below) which has a main screen with a button, a
tabcontrol and a couple of tab pages. I have two pre written forms that i
then put onto the tab pages. The problem i have is when i exit the forms in
the tabs i want to clear the text out of the tabpage (which is set in the
code below when they are loaded) but i cannot do it from the form as it won't
allow me at it and i have no way of actioning it back on the main screen when
one of the forms is exited.
Any help?

Public Class Form1
Inherits System.Windows.Forms.Form

" Windows Form Designer generated code "

Dim frm2 As New Form2
Dim frm3 As New Form3

Private Sub cmdLoad2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdLoad2.Click

frm2.TopLevel = False
frm2.Size = New Size(730, 340)
frm2.Visible = True
TabPage1.Controls.Add(frm2)

frm3.TopLevel = False
frm3.Size = New Size(730, 340)
frm3.Visible = True
TabPage2.Controls.Add(frm3)

TabPage1.Text = "This is form 2"
TabPage2.Text = "This is form 3"

End Sub

End Class
Nov 21 '05 #1
3 1042
RBirney,

Any control that you add, can as well be removed with remove, so seeing your
code is that my first answer.

I hope this helps,

Cor
Nov 21 '05 #2
"=?Utf-8?B?UkJpcm5leQ==?=" <RB*****@discussions.microsoft.com> wrote in
news:C6**********************************@microsof t.com:
I have a program (code below) which has a main screen with a button, a
tabcontrol and a couple of tab pages. I have two pre written forms
that i then put onto the tab pages. The problem i have is when i exit
the forms in the tabs i want to clear the text out of the tabpage
(which is set in the code below when they are loaded) but i cannot do
it from the form as it won't allow me at it and i have no way of
actioning it back on the main screen when one of the forms is exited.
Any help?

Public Class Form1
Inherits System.Windows.Forms.Form

" Windows Form Designer generated code "

Dim frm2 As New Form2
Dim frm3 As New Form3

Private Sub cmdLoad2_Click(ByVal sender As System.Object, ByVal e
As
System.EventArgs) Handles cmdLoad2.Click

frm2.TopLevel = False
frm2.Size = New Size(730, 340)
frm2.Visible = True
TabPage1.Controls.Add(frm2)

frm3.TopLevel = False
frm3.Size = New Size(730, 340)
frm3.Visible = True
TabPage2.Controls.Add(frm3)

TabPage1.Text = "This is form 2"
TabPage2.Text = "This is form 3"

End Sub

End Class


Put this on the forms. The parent control of the form is the tab page it
is on, so parent.text is the property you want to access. Overriding the
onclosing event will catch the form as it closes.

Protected Overrides Sub OnClosing(ByVal e As
System.ComponentModel.CancelEventArgs)
Parent.Text = ""
End Sub

Nov 21 '05 #3
"RBirney" <RB*****@discussions.microsoft.com> schrieb:
I have a program (code below) which has a main screen with a button, a
tabcontrol and a couple of tab pages. I have two pre written forms that i
then put onto the tab pages. The problem i have is when i exit the forms
in
the tabs i want to clear the text out of the tabpage (which is set in the
code below when they are loaded) but i cannot do it from the form as it
won't
allow me at it and i have no way of actioning it back on the main screen
when
one of the forms is exited.

Public Class Form1
Inherits System.Windows.Forms.Form

" Windows Form Designer generated code "

Dim frm2 As New Form2
Dim frm3 As New Form3

Private Sub cmdLoad2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdLoad2.Click

frm2.TopLevel = False


I suggest to use usercontrols instead of forms for the tabpages. Define an
event in your usercontrol that is raised when the usercontrol closes. In
the form, add a handler to the usercontrol's event to get notified when the
control closes. In the close event, remove the control from the tabpage's
'Controls' collection and remove the 'TabPage' from the tabcontrol's
'TabPages' collection.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: sameer mowade via .NET 247 | last post by:
Hello All, I have problem while dynamically removing row from the Datagrid which i have added dynamically as shown in the following code snippet. The problem is that while removing dynamically...
6
by: Sparky Arbuckle | last post by:
The code below works to an extent. The problem with it is that no matter which item is selected, the first one in the list is always the item that gets added/removed. How can I alleviate this...
2
by: Alan Silver | last post by:
Hello, I have discovered that if I try and add a cookie when one by that already exists, nothing happens. No error, but the cookie is not set to the new value. For example (this is running in...
0
by: Julien Fiore | last post by:
Hi, I have problems trying to install the scipy.weave package. I run Python 2.4 on windows XP and my C compiler is MinGW. Below is the output of scipy.weave.test(). I read that the tests should...
21
by: Alan Silver | last post by:
Hello, The latest incarnation of my troubles can be seen at www.kidsinaction/fd3/x.html - both HTML and CSS validate. I have two problems with it... 1) If you view this in FF, quite often the...
1
by: chr.aleksander | last post by:
Hey, I need a solution to two problems: #1 I use a three column layout, where the right and left columns are 150px wide and floated. The center column is not floated, with margins 150px on each...
2
by: melvinsdayout | last post by:
I have been having problems with IE 7 not responding to changes in the style sheet it is linked to. My problem is that my site looks good in Firefox, and was looking good in ie7 via an statement...
5
by: Jonathan Boivin | last post by:
Hi, I've got some problems with loading bills using a bill usercontrol I built. If I load all current bills in my test environment (156) everything is fine once, but repeating the operation...
23
by: tanya2001 | last post by:
hi all.. I am trying to update my datagrid in my webform...but its not getting updated..though in the database it removing the <null> and inserting a blank field....its not taking the input which m...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.