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

get objekts

hallo,
i hva got an form with ten textboxes
and now i want to set all text properties of each to "test"

is ther anpossibility to do this like this

for (i=0 ; i++, i>10)
setProp("text"+i.toStrin()", "text", "test");
thanks for your help
Nov 15 '05 #1
5 955
Abzieher Thomas <ta*****@etm-ag.com> wrote:
i hva got an form with ten textboxes
and now i want to set all text properties of each to "test"

is ther anpossibility to do this like this

for (i=0 ; i++, i>10)
setProp("text"+i.toStrin()", "text", "test");


You can use reflection if you really *have* to have that structure -
but it would be far better for your form to have a method which took
the text box number and the new value, and kept the textboxes
themselves in an array.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #2
Abzieher,

No, you will at some point have to loop through and make the method call
yourself.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Abzieher Thomas" <ta*****@etm-ag.com> wrote in message
news:10***************@newsmaster-03.atnet.at...
hallo,
i hva got an form with ten textboxes
and now i want to set all text properties of each to "test"

is ther anpossibility to do this like this

for (i=0 ; i++, i>10)
setProp("text"+i.toStrin()", "text", "test");
thanks for your help

Nov 15 '05 #3
You can set the text property of every text box on a form to a string like
this:

foreach (Control control in this.Controls)
if (control is TextBox)
((TextBox)control).Text = "test";
"Abzieher Thomas" <ta*****@etm-ag.com> wrote in message
news:10***************@newsmaster-03.atnet.at...
hallo,
i hva got an form with ten textboxes
and now i want to set all text properties of each to "test"

is ther anpossibility to do this like this

for (i=0 ; i++, i>10)
setProp("text"+i.toStrin()", "text", "test");
thanks for your help

Nov 15 '05 #4
Forms are parent controls, and therefore have a property called Controls
which is a ControlCollection (essentially a special array of controls) that
maintains a list of child controls within it. In order for a control to be a
child to a parent, it must be added to this collection. The form designer
will automatically generate this code for you when you drag a TextBox onto a
form, otherwise you must do it manually.

So! Every form automatically maintains a list of controls with in it (as do
panels, groupboxes, etc) and you can just use that. You can even single out
controls in the list by the Name or Tag properties or however else you'd
like to manipulate a subset of controls in the collection. I wrote code for
this elsewhere in the thread.

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
Abzieher Thomas <ta*****@etm-ag.com> wrote:
i hva got an form with ten textboxes
and now i want to set all text properties of each to "test"

is ther anpossibility to do this like this

for (i=0 ; i++, i>10)
setProp("text"+i.toStrin()", "text", "test");


You can use reflection if you really *have* to have that structure -
but it would be far better for your form to have a method which took
the text box number and the new value, and kept the textboxes
themselves in an array.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 15 '05 #5
Actually, this won't work as a control can also have sub controls.
you must use Recursion to travel down the tree of contained controls

JIM

"Eric" <ej********@yahoo.com> wrote in message
news:uH**************@TK2MSFTNGP10.phx.gbl...
You can set the text property of every text box on a form to a string like
this:

foreach (Control control in this.Controls)
if (control is TextBox)
((TextBox)control).Text = "test";
"Abzieher Thomas" <ta*****@etm-ag.com> wrote in message
news:10***************@newsmaster-03.atnet.at...
hallo,
i hva got an form with ten textboxes
and now i want to set all text properties of each to "test"

is ther anpossibility to do this like this

for (i=0 ; i++, i>10)
setProp("text"+i.toStrin()", "text", "test");
thanks for your help


Nov 15 '05 #6

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

Similar topics

3
by: Kim Lots | last post by:
Hi all I'm trying to pass two variables, but what is wrong with my code? -------- <form name="uno" action="validate.asp?Num=<%=Request.Querystring("Num") %>" method="post"> <textarea...
3
by: Nils | last post by:
Hi, Ich have a template class and want to initialize a static variable, that is available for all objekts of the template class, doesn't matter what template parameter is used. Can someone please...
6
by: Michael S. | last post by:
Hi I'm having some problems with a class for large Integers (called Xuint). I want (have) to implement it like this: - using a simple linked list - a reference-objekt for each value, which...
1
by: news.online.no | last post by:
Hello What kind of Objekts is safe to return in a Web service? (will work ok) Where can I find a list of these I have found out that a collection or an unspesifyed Stringarray do not return....
3
by: Zeh Mau | last post by:
Virtuelle Konstruktoren Ich habe gerade gelesen: Konstruktoren dürfen nicht virtuell deklariert werden, da beim Erzeugen von Objekten immer die tatsächliche Klasse bereits zur Compilezeit...
7
by: Thomas | last post by:
I am compiling with g++ the fol. class: template<typename E> class C_vector_ : public std::vector<E> { private:
7
by: Peter Hansch | last post by:
Hallo, habe ein VS02 Projekt konvertiert auf VS05. Es handelt sich um eine Klasse zur erzeugung eines Screenshots Dabei tritt oben genannter Fehler auf an. Und zwar bei markierter Stelle: ...
0
by: Olli Goessler | last post by:
Hi Guys, (sorry for my bad english) i have a question for the following problem: With the RSACryptoServiceProvider object... Application A: // Generate a public/private key pair....
9
by: =?Utf-8?B?bnV1dHV1ZG5ldA==?= | last post by:
We want to use allready written C sharp programs for our asp.net applications. The idea is that we write a program ONCE and use this same EXACT logic for our internet apps. Everything will run on...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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,...
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
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.