|
-
May 5th, 2004, 01:03 PM
#1
Thread Starter
Member
Clear Textboxes on forms
Hello,
How can I clear textboxes on a form other than like this....
txtProductID.Text = ""
txtProductName.Text = ""
txtQtyPerUnit.Text = ""
if I have 225 textboxes on several pageframes in an application this would take forever. Is not there a way to setall textboxes.text = ""?
FoxT
Always lookin' for an easier way!
-
May 5th, 2004, 01:42 PM
#2
here's one of many ways ...
VB Code:
Dim ctl As Control
For Each ctl In Controls
If ctl.GetType.IsAssignableFrom(GetType(TextBox)) Then
ctl.Text = ""
End If
Next
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
-
May 5th, 2004, 02:02 PM
#3
Thread Starter
Member
Another question
dynamic_sysop,
That looks like a good way to do this, however it did not work in my app. I'm using the native VB.net textboxes with the text property. Do have have to modify something for this. They do clear when I issue this...
txtProductID.Text = ""
txtProductName.Text = ""
txtQtyPerUnit.Text = ""
FoxT
Always lookin' for an easier way!
-
May 5th, 2004, 02:10 PM
#4
VB Code:
Dim ctl As TextBox
For Each ctl In Me.Controls
ctl.Text = ""
Next
-
May 5th, 2004, 02:54 PM
#5
Thread Starter
Member
Not there yet.
Ok, here is where I am at now.
I cannot get this routine to work on any of my applications...
Dim ctl As TextBox
For Each ctl In Me.Controls
ctl.Text = ""
Next
however I can get this one to work on a regular form...
Dim ctl As Control
For Each ctl In Controls
If ctl.GetType.IsAssignableFrom(GetType(TextBox)) Then
ctl.Text = ""
End If
Next
but what I need is to clear a form with a pageframe. And to clear all textboxes on the different tabs on the pageframe.
Thanks,
FoxT
Always lookin' for an easier way!
-
May 5th, 2004, 02:59 PM
#6
Thread Starter
Member
I got it now
Ok, I have it now.
Dim ctl As Control
For Each ctl In TabPage1.Controls
If ctl.GetType.IsAssignableFrom(GetType(TextBox)) Then
ctl.Text = ""
End If
Next
For Each ctl In TabPage2.Controls
If ctl.GetType.IsAssignableFrom(GetType(TextBox)) Then
ctl.Text = ""
End If
Next
Thanks,
FoxT
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
|