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

Dynamically accessing UI controls on a C# Windows Form

Hi,

I have a C# windows form. Initially i might have just a Label and a Text Box present on the form. Then later when there are new requirements i might be adding additional UI controls.

What i want now is I need a way to identify the controls present currently on the form dynamically and set their properties. In my case i specifically want to increase the "Font Size" of all the UI controls present on the form.
Jun 13 '07 #1
2 1606
This will loop through all controls on a form, if run from within the form.


Expand|Select|Wrap|Line Numbers
  1. int count=this.Controls.Count;
  2. for (int x = 0; x < count; x++)
  3.  this.Controls[x].PROPERTYNAME....

You would have to use cast the control to its specific subclass in order to access type specific properties.
Also, I believe fonts for most (if not all) controls are static, but i could be wrong.
Jun 13 '07 #2
nmsreddi
366 256MB
Hello

Creating a control dynamically at run time is fine,but how to get the id of the particular control ,what will ethe default id for those controls generated dynamically, because once we get the id of a particular control ,getting properties all those are not a problem

Any idea please reply


Thanks
Jun 15 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Ahmet | last post by:
Hi; How can I get control list (Controls) of a form in a dll dynamically activated using Activators.CreateInstance. I need all controls names and attributes of one form which is in one dll. Is...
1
by: CS Wong | last post by:
Hi, I have a page form where form elements are created dynamically using Javascript instead of programatically at the code-behind level. I have problems accessing the dynamically-created...
2
by: Vivek Sharma | last post by:
Hi There, I have a situation where I wish to load the controls dynamically on the basis of user role. Hence, I am using this code. if (UserRole == "IS Administrator") { Control UC1 =...
2
by: Ahmet | last post by:
Hi; How can I get control list (Controls) of a form in a dll dynamically activated using Activators.CreateInstance. I need all controls names and attributes of one form which is in one dll. Is...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...

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.