473,569 Members | 2,601 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1436
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 BetaClearTextBo xes(ByVal PanelName As Panel)
Dim txb As Control
For Each txb In PanelName.Contr ols
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 BetaClearTextBo xes(ByVal PanelName As Panel)
Dim txb As TextBox
For Each txb In PanelName.Contr ols
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**********@p lanet.nl> wrote in message
news:et******** ******@tk2msftn gp13.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***@jonharve y.com> wrote in message
news:%2******** *******@TK2MSFT NGP11.phx.gbl.. .
If I use this code:

Sub BetaClearTextBo xes(ByVal PanelName As Panel)
Dim txb As Control
For Each txb In PanelName.Contr ols
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 BetaClearTextBo xes(ByVal PanelName As Panel)
Dim txb As Control
For Each txb In PanelName.Contr ols
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.s pam> wrote in message
news:Op******** *****@TK2MSFTNG P09.phx.gbl...

"Aaron" <aa***@jonharve y.com> wrote in message
news:%2******** *******@TK2MSFT NGP11.phx.gbl.. .
If I use this code:

Sub BetaClearTextBo xes(ByVal PanelName As Panel)
Dim txb As Control
For Each txb In PanelName.Contr ols
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**********@p lanet.nl> wrote in message
news:el******** ******@tk2msftn gp13.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**********@p lanet.nl> wrote in message
news:eF******** ******@TK2MSFTN GP11.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

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

Similar topics

7
3500
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) template. Briefly -------------------------------------------------------------------------------------------- I need to create dynamically some...
1
3140
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 many questions. To keep it simple, I'll describe the basics of what I'm trying to design. I've created a TextBox composite control that...
0
2051
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 is on. This works fine only if one closes the panels from last panel. Otherwise two clicks is necessary for the last panel - ie, if you press add 3...
6
2230
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 corrent number of controls. The problem is that they appear next to each other. I want to create the controls with some wording to the left of them...
4
2078
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. Each question is displayed and answered, then result written to a SQL table. Then the next question is read from a table and displayed using the...
3
1087
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 the entire application I want to print the name of all forms to the debug window. TIRislaa
2
1070
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 ctr.text = "" End If
15
6492
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 accept other controls. The control i drag drop on it becomes the child of my custom control's parent form and not the child of my custom control. Then...
4
3479
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 experimenting before getting to the actual part. This is what I am trying to do: * Create a tab container dynamically * Create 5 tabs dynamically ...
0
7701
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, 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...
0
7615
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8130
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7677
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7979
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6284
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3653
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...
1
2115
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
1
1223
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.