472,353 Members | 1,393 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,353 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 6501
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...
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. ...
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...
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...
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...
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...
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...
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...
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...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...

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.