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
Printable View
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
Can you refresh the form instead? You can do myForm.Refresh().
Or to re-instantiate you can do:
frmForm = New frmForm(....)
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
Are you using Shared methods?
You have to first instantiate the form (using the "New" keyword) before you can refresh it.
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
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 .
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
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