|
-
Apr 9th, 2003, 06:29 AM
#1
Thread Starter
New Member
Reinitializing forms
Hello,
I'm rather new to VB.net so I'm wondering how to reinitialize form (or to reset them)?
I hava program that does something, I want to be able to reset it on button click (or something).
Any help appreciated
Thanx
Krvolok
-
Apr 9th, 2003, 07:55 AM
#2
Fanatic Member
Can you refresh the form instead? You can do myForm.Refresh().
Or to re-instantiate you can do:
frmForm = New frmForm(....)
-
Apr 9th, 2003, 09:10 AM
#3
Thread Starter
New Member
Thanx,
Refresh is what I had in mind.
When I try to do somethng like 'Form1.Refresh()' from Public Sub I do receive an error message: "Reference to a non-shared member requires an object reference"
Any idea how to avoid this?
Krvolok
-
Apr 9th, 2003, 09:22 AM
#4
Fanatic Member
Are you using Shared methods?
You have to first instantiate the form (using the "New" keyword) before you can refresh it.
-
Apr 9th, 2003, 09:48 AM
#5
Thread Starter
New Member
Thanx, I've made a new instance and it works (kinda). Also, myform.Show() does the job but it pops another form on the screen.
Here is what I want exactly:
I have a form with buttons, check boxes, text boxes, etc...
They all get some values as the program runs. Now I want to reset all list boxes, check boxes etc.. on a button click.
I've done that manualy for each element on the form.
Is there a way to reset them all to their beginning state?
Krvolok
-
Apr 9th, 2003, 01:48 PM
#6
Sleep mode
You can loop through all controls on the form to have them set to your default values . You have to use For ...Next and TypeOf keywords in this case .
-
Apr 9th, 2003, 05:06 PM
#7
Thread Starter
New Member
Hmm..
I've tried this:
For i = i to Me.Controls.Count
If TypeOf Me.Controls(i) is CheckBox then
Controls(i).???
Next
How can I change properties of number 'i' control?
In this case something like Controls(i).checked = false
Krvolok
-
Apr 9th, 2003, 06:29 PM
#8
Sleep mode
Create three or more textboxes then paste this code in command to reset all these textboxes :
VB Code:
Dim ctrl As Control
Dim txtbox As Control
For Each txtbox In Me.Controls
If TypeOf txtbox Is TextBox Then
txtbox.Text = ""
End If
Next
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|