473,387 Members | 1,572 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,387 software developers and data experts.

iterate through a set of controls

Hi

In VB.net

I have a set of linkButtons controls in a form , which I want to iterate on
them and change their text property.

How it's done ?

thanks

Nov 21 '05 #1
4 6570
Dim c As Control

For Each c In Me.Controls
If TypeOf c Is LinkButton Then
c.Text = "Bla Bla"
End If
Next c

Crouchie1998
BA (HONS) MCP MCSE
Nov 21 '05 #2
"romy" <ro******@Powerup1.com> schrieb:
I have a set of linkButtons controls in a form , which I want to iterate
on them and change their text property.


Web Forms or Windows Forms?

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #3
Romy,

\\\
Dim frm As Control = Me.FindControl("Form1")
For Each ctl as Control In frm.Controls
if TypeOf ctl Is Linkbutton Then
DirectCast(ctl, Linkbutton).Text = "WathEver"
End If
Next
///

I hope this helps,

Cor
Nov 21 '05 #4
"romy" <ro******@Powerup1.com> wrote in message
news:uz**************@TK2MSFTNGP12.phx.gbl...
I have a set of linkButtons controls in a form, which I want to
iterate on them and change their text property.


You /could/ loop through the Controls collection of the Form,
looking for LinkButtons. Sadly, this /only/ works when all the
LinkButtons are actually placed /on/ the Form and not inside
any "container" controls, like Panels or GroupBoxes, in which
case you have to [recursively] scan the Controls Collection of
each container!

Alternatively, if the LinkButtons are all set up at Design Time,
create a - gasp - Control Array. No, don't laugh; I actually
mean an Array of Controls or, in this case, of LinkButtons, as in

Private AllLinkButtons as LinkButton() = { _
Me.LinkButton1, Me.LinkButton2, Me.LinkButton3
...
}

Then, you can simply use

For Each eLB as LinkButton in AllLinkButtons
eLB.Text = "whatever"
Next

HTH,
Phill W.
Nov 21 '05 #5

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

Similar topics

2
by: Simon | last post by:
I've got a webform and many controls on it. I would like to iterate thru the control collection to get all the textboxes control to let me change the text property. Here is my code...for unknown...
2
by: James Doran | last post by:
Hello, I'd like to iterate through each Page of my ASP.NET project from within a Custom web control and access the Page.Controls collection. I've tried using Reflection on the web project...
2
by: Tina | last post by:
I need to find all of the datagrids on a page. How can I iterate through all of the controls on a page to get their name and grab them as an object? thanks, T
2
by: Oleg | last post by:
Let's say I rendered a bunch of controls with the same name and different IDs. On postback, can I somehow iterate through these controls (checkboxes in this case, but could be dropdown controls in...
7
by: Rich | last post by:
Hello, I have a form with 5 textboxes named txt0, txt1, txt2, txt3, tx4. In VB6 I could iterate through these with For i = 0 to 4 debug.print Me.controls("txt" & i).Name Next
2
by: A | last post by:
HI all, I am trying to iterate over all the controls on my form and if a control IS A textbox then I want to enter the If statement. So far I can't get it to work...here is the code...any...
0
by: Rob Meade | last post by:
Hi all, I have a page, where, because it had to all be in one page there are a multitude of panels, with the use of a handful of conditions and the ability to show/hide panels I am able to make...
9
Shashi Sadasivan
by: Shashi Sadasivan | last post by:
In my current application, I have to set cettain defaults to controls that are displayed or are used. so i have a class to which i send the form as a control, and iterate through each of its...
2
by: Luqman | last post by:
I have a Ajax Tab Container on my Webform with One Panel and some Labels and Textboxes. I want to Iterate through all the textboxes and return their IDs. I tried every possibility I could but...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
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
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.