Tech
Forums
Jobs
Books
Events
Live
Interviews
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
2
Reply
C# - How to iterate a form's custom controls
Walter Kiess
Mar 19 2012 12:22 AM
2.1k
Reply
Hi C# Gurus,
I have created my own custom Textbox control which I intend to use on every form in my application rather than the standard Textbox control.
One of the things I do when the app starts is to call a common routine/method/procedure (call it what you will) which iterates thru all the controls on the form, settings it's colours according to the user selected colour scheme. This all works fine for the standard window's controls, but not for the custom control's new property:
FocusColour
. I'm using a pretty standard loop to iterate thru the controls:
foreach(Control c
in
f
.Controls
){}
When it hits the custom textbox control, setting the Back and ForeColor properties works fine, but I can't set the new
FocusColour
property because it doesn't appear in intellisense and the program won't run (shows errors) if I manually type the property i.e.
c
.FocusColour
= Colors
.Yellow
;
My question is: How can I iterate thru all the
custom
controls on the form to set the new properties, or how can I include the custom properties once a custom control is found in the above loop?
Thanks in advance,
Walter
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
2
)
Next Recommended Forum
Invoking a delegate asynchronously
How to find the id of dragged control.