Hello:
I have 20, 30 text and combo boxes on one form, and I would like to clear
them up at one time using the statement "With.......... End With".
I used this when using VB6, but I don't know if I can use the same way in
VB.Net. If I can't use With statement in VB.Net, what should I do?
Thanks!! 13 29192
Dim ctrl As Control
Dim txt As TextBox
For Each ctrl In Me.Controls
If (ctrl.GetType() Is GetType(TextBox )) Then
txt = CType(ctrl, TextBox)
txt.Text = ""
End If
Next
"KKuser" <a.*@c.d.com> ha scritto nel messaggio
news:O3******** ******@TK2MSFTN GP09.phx.gbl... Hello:
I have 20, 30 text and combo boxes on one form, and I would like to clear them up at one time using the statement "With.......... End With".
I used this when using VB6, but I don't know if I can use the same way in VB.Net. If I can't use With statement in VB.Net, what should I do?
Thanks!!
-----Original Message-----
Hi
I use the following procedures to clear the text.
They use System.Reflecti on
Kind Regards
Jorge
PS: Its in Portuguese ...
Limpa=clean,meu form=myform,cam pos=field...
Public Sub LimpaTextBoxes( ByVal f As Form)
Dim meuForm As Type = f.GetType()
Dim campos As FieldInfo() = meuForm.GetFiel ds
(BindingFlags.I nstance Or BindingFlags.No nPublic)
For Each campo As FieldInfo In campos
If campo.FieldType .Name.ToLower = "textbox"
Then
Dim t As TextBox = DirectCast
(campo.GetValue (f), TextBox)
t.Text = ""
End If
Next
End Sub
Public Sub LimpaComboBoxes (ByVal f As Form)
Dim meuForm As Type = f.GetType()
Dim campos As FieldInfo() = meuForm.GetFiel ds
(BindingFlags.I nstance Or BindingFlags.No nPublic)
For Each campo As FieldInfo In campos
If campo.FieldType .Name.ToLower = "combobox"
Then
Dim c As ComboBox = DirectCast
(campo.GetValue (f), ComboBox)
c.Text = ""
End If
Next
End Sub
Hello:
I have 20, 30 text and combo boxes on one form, and I
would like to clearthem up at one time using the
statement "With.......... End With". I used this when using VB6, but I don't know if I can
use the same way inVB.Net. If I can't use With statement in VB.Net, what
should I do? Thanks!!
.
Hi KKuser,
It looks the same as the others, however it is not, it cleans also when a
textbox or a combobox is places in another control as by instance a
groupbox.
(I changed it from something else so watch typos)
I hope this helps?
Cor
Private Sub Form1_Load(ByVa l sender As Object, _
ByVal e As System.EventArg s) Handles MyBase.Load
doclean(Me)
End Sub
Private Sub doSet(ByVal parentCtr As Control)
Dim ctr As Control
For Each ctr In parentCtr.Contr ols
if typeof ctr Is textbox then
ctr.txt = ""
doSet(ctr)
elseif typeof ctr Is combobox then
ctr. 'cleaning up depends here if you use the itemarray or the
datasource
Next
End Sub
* "KKuser" <a.*@c.d.com> scripsit: I have 20, 30 text and combo boxes on one form, and I would like to clear them up at one time using the statement "With.......... End With".
You cannot.
I used this when using VB6, but I don't know if I can use the same way in VB.Net. If I can't use With statement in VB.Net, what should I do?
How did you do that with the 'With' statement in VB6?
<URL:http://dotnet.mvps.org/dotnet/samples/controls/downloads/EnumerateContro ls.zip>
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Hello all:
Thank you for your advises, I have solved my problem.
In fact, my biggest problem is that I put all the textboxes in a groupbox,
but I didn't "mention" it in my codes.
For Each ThisControl In Me.GroupBox3.Co ntrols
^^^^^^^^^
I should have added this.......
And another question...
In the same case, I just want to clear the text of the comboboxes, but keep
the options contained in it (ie. still keep all items in "Combobox.Items ").
I have tried
ThisControl.Tex t = ""
("thiscontro l" now means a combobox)
, but it doesn't work. How to do that??
Thanks again !!
Hello all:
Thank you for your advises, I have solved my problem.
In fact, my biggest problem is that I put all the textboxes in a groupbox,
but I didn't "mention" it in my codes.
For Each ThisControl In Me.GroupBox3.Co ntrols
^^^^^^^^^
I should have added this.......
And another question...
In the same case, I just want to clear the text of the comboboxes, but keep
the options contained in it (ie. still keep all items in "Combobox.Items ").
I have tried
ThisControl.Tex t = ""
("thiscontro l" now means a combobox)
, but it doesn't work. How to do that??
Thanks again !!
Hi KKuser,
Which code did you try, I wrote that the code I was providing was doing all
this you wrote in this message..
With the difference that it becomes for the combobox then of course
elseif typeof ctr Is combobox then
ctr.selectedind ex = -1
end if
I do not understand that this does not work, can you tell what goes wrong?
Cor Thank you for your advises, I have solved my problem.
In fact, my biggest problem is that I put all the textboxes in a groupbox, but I didn't "mention" it in my codes.
For Each ThisControl In Me.GroupBox3.Co ntrols ^^^^^^^^^ I should have added this.......
And another question... In the same case, I just want to clear the text of the comboboxes, but
keep the options contained in it (ie. still keep all items in
"Combobox.Items "). I have tried
ThisControl.Tex t = "" ("thiscontro l" now means a combobox)
, but it doesn't work. How to do that??
Thanks again !!
Hello Cor:
Thank you for your reply!! My code is :
Dim ThisControl As Control
...........
...........
...........
If TypeOf ThisControl Is ComboBox Then
ThisControl.Sel ectedIndex = -1
End If
But the "ThisControl.Se lectedIndex = -1" line is marked due to
"SelectedIn dex is not a member of 'System.Windows .Forms.Control' "
That's why I said it doesn't work......
"Cor Ligthert" <no**********@p lanet.nl> ¦b¶l¥ó
news:uS******** ******@TK2MSFTN GP12.phx.gbl ¤¤¼¶¼g... Hi KKuser,
Which code did you try, I wrote that the code I was providing was doing
all this you wrote in this message..
With the difference that it becomes for the combobox then of course
elseif typeof ctr Is combobox then ctr.selectedind ex = -1 end if
I do not understand that this does not work, can you tell what goes wrong?
Cor
Thank you for your advises, I have solved my problem.
In fact, my biggest problem is that I put all the textboxes in a
groupbox, but I didn't "mention" it in my codes.
For Each ThisControl In Me.GroupBox3.Co ntrols ^^^^^^^^^ I should have added this.......
And another question... In the same case, I just want to clear the text of the comboboxes, but
keep the options contained in it (ie. still keep all items in "Combobox.Items "). I have tried
ThisControl.Tex t = "" ("thiscontro l" now means a combobox)
, but it doesn't work. How to do that??
Thanks again !!
Hi KKuser,
I did it this time very quick and dirty I saw, sorry for this,
Take this routine it is really fine, it is a real recursive routine which
solves all problems with controls in controls and what is more, which you
see often solved in long lines of code.
Now I have tested it as a cleaner (It was a sample of setting a tooltip I
once made).
I hope it works for you as well?
Cor
\\\
Private Sub Form1_Load(ByVa l sender As Object, _
ByVal e As System.EventArg s) Handles MyBase.Load
doclean(Me)
End Sub
Private Sub doclean(ByVal parentCtr As Control)
Dim ctr As Control
For Each ctr In parentCtr.Contr ols
If TypeOf ctr Is TextBox Then
ctr.Text = ""
ElseIf TypeOf ctr Is ComboBox Then
DirectCast(ctr, ComboBox).Selec tedIndex = -1
End If
doclean(ctr)
Next
End Sub
/// This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Martin Hazell |
last post by:
For various reasons, I have had to produce a quick (!) page to edit one column of data in a database with ASP.net. With this being my first foray into ASP.net, I apoligise for any basic erros I have made.
The main problem is when setting up an ASP.net datagrid, which I can edit the single value of a specific column. I have wired up the update and edit methods to change the current edit row. I worked through the example in the MSDN help to...
|
by: Steve B. |
last post by:
Using: VS
dB: MS-Access
Although the the DataGrid displays the proper date from an Access file
(Date/Time DataType) an adjacent bound textbox for that same DataGrid field
displays the date and the time (e.g. 12/7/04 12:00 AM).
How do I get rid of the time from textbox and show only the date?
1. VS textbox Properties:
|
by: BradC |
last post by:
We have a Windows 2000 web server (all patches up to date) that runs a
variety of sites, most of which are straight HTML or ASP.
We have recently added a couple of new ASP.NET sites that use ADO.NET to
connect to (different) SQL databases on another server. A couple of times a
week, these new ASP.NET sites suddenly become unavailable (the client
browser times out with no error message).
Its not even the entire site, either. The welcome...
|
by: Patrick.O.Ige |
last post by:
Whats the best way to clear textboxes?
Any ideas?
|
by: CsaaGuy |
last post by:
Hi, I created a class in ap.net using vb.net that inherits from
Textbox. I added a few of my own properties and methods, set it up to
appear in the toolbox. And have used it. My properties that appear on
the toolbar work fine at design time. I set them at design time and all
works fine. I can access them later, they retain value and work.
However, when I try to set them at run time, they set but when the page
posts back, the data has...
| |
by: jason |
last post by:
I've seen a few posts on this issue, but no clear solutions.
I have a mulitiline textbox inside a datagrid.
I use TemplateColumn to define as multiline with 3 rows.
I have other field types like drop downs that have no issue displaying
last values in edit mode with seemingly more complicated code.
when I attempt to find my textbox with
|
by: MR |
last post by:
Hi,
it has been observed that when we try to instantiate
a .Net dll for the first time in a session (e.g. from an
exe in .Net), it takes almost 10 times compared to
subsequent instantiations.
We have A.exe, developed in VB.Net, where, in a button
click, we are instantiating the Test.dll also developed in
VB.Net. We run three instances of A.exe simultaneously
(say A1, A2 and A3 are the three instances). Clicking on
|
by: Leonardo Santos-Macias |
last post by:
I have an asp.net textbox with some EULA and a button to accept the EULA.
The textbox will have scrollbars since the EULA is several pages. Is there
any way using asp.net, vbscript or jave to detect if the user scrolled the
textbox down to the bottom?
Thanks in advance
|
by: Ravi Ambros Wallau |
last post by:
Hi:
We developed a set of ASP.NET Web Applications that never runs in
stand-alone mode, but always inside a portal (Rainbow Portal). All modules
are copied on that portal.
My question is: load time takes, sometimes, three or four of minutes in
a medium-level machine (a PIII 1.5 Ghz), when the binary contents are
changed, or if the time of last modification of the web.config file is
changed.
An application that runs in "stand-alone" mode...
|
by: g7murali123 |
last post by:
hi, my textbox contains text as "search" on pageload when the user click the textbox the text "search" should disappear and the textbox must get the value of the user entering text. please help the guide for this event in asp.net c#
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |