473,407 Members | 2,598 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,407 software developers and data experts.

Finding controls on a panel

Is there a way to get the names of all of the textboxes that are placed on a
panel?

I have several panels on my .NET application, each with several textbox
controls. I would like to get all of the names of the textboxes and clear
to text values without manually typing out all of the names. Is there an
easy way to specify the panel that these controls are placed in and get
those names?

something like

for each textbox on panel1
textbox.value =""
next

Thanks,
Aaron
Nov 21 '05 #1
12 1419
Aaron

You are there almost

for each textbox on panel1
textbox.value =""
next

for each txb as control on panel1.controls
if typeof txb Is textbox then
txb.text = ""
end if
next

I hope this helps?

Cor
Nov 21 '05 #2
If I use this code:

Sub BetaClearTextBoxes(ByVal PanelName As Panel)
Dim txb As Control
For Each txb In PanelName.Controls
If TypeOf txb Is TextBox Then
txb.text = ""
End If
Next
End Sub

Intellisense gives me an error stating that "text" is not a member of
"Control".
If I use this code (Dim txb as textbox instead of control)

Sub BetaClearTextBoxes(ByVal PanelName As Panel)
Dim txb As TextBox
For Each txb In PanelName.Controls
If TypeOf txb Is TextBox Then
txb.text = ""
End If
Next
End Sub

I get Specified cast is not valid.
This errors out on the for each txb line.

Any ideas?

Thanks,
Aaron

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:et**************@tk2msftngp13.phx.gbl...
Aaron

You are there almost

for each textbox on panel1
textbox.value =""
next

for each txb as control on panel1.controls
if typeof txb Is textbox then
txb.text = ""
end if
next

I hope this helps?

Cor

Nov 21 '05 #3

"Aaron" <aa***@jonharvey.com> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
If I use this code:

Sub BetaClearTextBoxes(ByVal PanelName As Panel)
Dim txb As Control
For Each txb In PanelName.Controls
If TypeOf txb Is TextBox Then
txb.text = ""
End If
Next
End Sub

Intellisense gives me an error stating that "text" is not a member of
"Control".


Try

DirectCast(txb, TextBox).Text = ""
Nov 21 '05 #4
Yeas, this code works:
Sub BetaClearTextBoxes(ByVal PanelName As Panel)
Dim txb As Control
For Each txb In PanelName.Controls
If TypeOf txb Is TextBox Then
DirectCast(txb, TextBox).Text = ""
End If
Next
End Sub

Thanks for the help! I had never heard of DirectCast...

Aaron

"Jeff Johnson [MVP: VB]" <i.***@enough.spam> wrote in message
news:Op*************@TK2MSFTNGP09.phx.gbl...

"Aaron" <aa***@jonharvey.com> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
If I use this code:

Sub BetaClearTextBoxes(ByVal PanelName As Panel)
Dim txb As Control
For Each txb In PanelName.Controls
If TypeOf txb Is TextBox Then
txb.text = ""
End If
Next
End Sub

Intellisense gives me an error stating that "text" is not a member of
"Control".


Try

DirectCast(txb, TextBox).Text = ""

Nov 21 '05 #5
brrrrrrrrrr I typed it direct in the message, this error I make seldom

And I knew I was missing something.

:-)

Thanks

Cor
Nov 21 '05 #6

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:el**************@tk2msftngp13.phx.gbl...
brrrrrrrrrr I typed it direct in the message, this error I make seldom


We call that "air code."
Nov 21 '05 #7
Aaron,

I first was thinking I was making a quick typing mistake, however it can not
give an error.

Textbox derives text from control and therefore casting is not necessary.
So text is a property from Control. So how can you get the message that text
is not a property from Control.

I am curious why you got this?

Cor
Nov 21 '05 #8
Jeff,
brrrrrrrrrr I typed it direct in the message, this error I make seldom


We call that "air code."

It was no typing mistake, when I answered it was late in evening here, so I
was direct thinking on an error. However casting should not be necessary
here because Text is a property from Control and I stopped to type the
casting with that and did that automaticly as well in this message.

Cor
Nov 21 '05 #9

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:eF**************@TK2MSFTNGP11.phx.gbl...
brrrrrrrrrr I typed it direct in the message, this error I make seldom
We call that "air code."

It was no typing mistake, when I answered it was late in evening here, so

I was direct thinking on an error. However casting should not be necessary
here because Text is a property from Control and I stopped to type the
casting with that and did that automaticly as well in this message.


Hmmm, you're right. It looks like it should work. I'll test it when I get a
chance.
Nov 21 '05 #10
Text is not a property of control. At least not in asp.net.

If I do :
Dim C as control
C.text does not exist

Aaron

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:uA**************@TK2MSFTNGP10.phx.gbl...
Aaron,

I first was thinking I was making a quick typing mistake, however it can not give an error.

Textbox derives text from control and therefore casting is not necessary.
So text is a property from Control. So how can you get the message that text is not a property from Control.

I am curious why you got this?

Cor

Nov 21 '05 #11
* "Aaron" <aa***@jonharvey.com> scripsit:
Text is not a property of control. At least not in asp.net.


ACK. Then I would suggest to cast to the type of the class that
provides the property.

--
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 #12
Aaron,

When in this newsgroup is not told it is a webform than it is by default a
windowform when there are 2 possibilities.

In your message you did not tell, not a member of "web.ui.control" however
even "control". A panel is as well on a windowform as on a webform.

When it is a webform, than you would do that casting to get the right
object.

However I am glad you messaged it because I did absolute not understand it,
and was not thinking about a webform, because I thought that it needs
something more on a webform. Now I saw that that more is not when it is on a
panel but when it is direct on the page.

:-)

Cor
Text is not a property of control. At least not in asp.net.

If I do :
Dim C as control
C.text does not exist

Aaron

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:uA**************@TK2MSFTNGP10.phx.gbl...
Aaron,

I first was thinking I was making a quick typing mistake, however it can

not
give an error.

Textbox derives text from control and therefore casting is not necessary. So text is a property from Control. So how can you get the message that

text
is not a property from Control.

I am curious why you got this?

Cor


Nov 21 '05 #13

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

Similar topics

7
by: Bil Muh | last post by:
Esteemede Developers, I would like to Thank All of You in advance for your sincere guidances. I am developing a software using Visual C++ .NET Standard Edition with Windows Form (.NET)...
1
by: sleigh | last post by:
Hello, I'm building a web application that will build a dynamic form based upon questions in a database. This form will have several different sections that consist of a panel containing one to...
0
by: mawi | last post by:
Hello, Description: I create panels with some controls on a page using a new panel button. One of the controls on each panel is the "close panel" button that is supposed to close the panel it...
6
by: dhnriverside | last post by:
Hi peeps, I'm trying to create some controls textboxes at runtime, based on the number of items in a IETreeView that are checked. That I can do, I've got a place holder and I can create the...
4
by: Bass Pro | last post by:
Hi, I am creating textbox, radiobuttonlist and checkboxlist dynamically depending on data from a table. It is a questionnaire. I add the control on a Panel control during the 1st load_page event....
3
by: Tor Inge Rislaa | last post by:
Finding name and type In the activate procedure of a form I want to write to the debug window, name and type of all controls at that actual form. Is there a smart way to do that? Allso for...
2
by: IdleBrain | last post by:
Hello, I am trying to write code to clear all the textboxes on a VB.NET windows form using: Dim ctrl As Control For Each ctrl In Me.Controls 'Add your code here If TypeOf ctrl Is TextBox Then...
15
by: rizwanahmed24 | last post by:
Hello i have made a custom control. i have placed a panel on it. I want this panel to behave just like the normal panel. The problem i was having is that the panel on my custom control doesnt...
4
by: karthik25 | last post by:
Hi All, I have a problem in finding control in a dynamically created updated panel. I have given the code below. Following is just a starting effort in a completely dynamic user control. I am...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.