Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Dec 13th, 2007, 1:41 AM   #1
abajan
Newbie
 
Join Date: Dec 2007
Posts: 2
Rep Power: 0 abajan is on a distinguished road
Select a control by name

hi ;
I create some check box control in my form and i want to select it by its name
(set focus control by it name ) . woul you please help me?
abajan
abajan is offline   Reply With Quote
Old Dec 13th, 2007, 1:49 AM   #2
Klipt
Hobbyist Programmer
 
Join Date: Dec 2005
Posts: 118
Rep Power: 0 Klipt is an unknown quantity at this point
Re: Select a control by name

CheckBox1.SetFocus;
should work; just replace 'CheckBox1' with the actual name.
Klipt is offline   Reply With Quote
Old Dec 15th, 2007, 1:40 AM   #3
abajan
Newbie
 
Join Date: Dec 2007
Posts: 2
Rep Power: 0 abajan is on a distinguished road
Re: Select a control by name

Quote:
Originally Posted by Klipt View Post
CheckBox1.SetFocus;
should work; just replace 'CheckBox1' with the actual name.
Thank you ;
But I want select a group of check box in loop for example
for i:=1 to 10 do
{select controls by its name}
abajan
abajan is offline   Reply With Quote
Old Dec 15th, 2007, 2:57 AM   #4
grumpy
Programming Guru
 
grumpy's Avatar
 
Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,198
Rep Power: 5 grumpy is on a distinguished road
Re: Select a control by name

You have to create an array of pointers to TCheckBox, initialise that array so the first element points to CheckBox1, the second to CheckBox2, etc etc. Then you can loop over that array.
grumpy is offline   Reply With Quote
Old Dec 15th, 2007, 4:50 AM   #5
Klipt
Hobbyist Programmer
 
Join Date: Dec 2005
Posts: 118
Rep Power: 0 Klipt is an unknown quantity at this point
Re: Select a control by name

Do you mean you want to tick a group of checkboxes? This is different to setting the focus on a checkbox. The focus is the dotted border that shows which control is currently responding to keyboard input, and only one control can have it at a time. So a loop which sets the focus on a group of controls will effectively only set the focus on the last one.

To tick a checkbox, you can use
CheckBox1.Checked = True;

When you say by name, do you know the names at design time or runtime (as strings)? You can use Grumpy's method in the former case.
Klipt is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Version control Mad_guy Coder's Corner Lounge 6 Jul 18th, 2007 2:46 PM
How to add inherited control to toolbox. InfoGeek C# 3 Feb 8th, 2007 9:12 PM
Coding standards without control? martinig Other Programming Languages 1 Dec 4th, 2006 7:04 AM
C programing control of the Serial Port. Light C++ 5 Feb 24th, 2005 2:14 PM
Show web user control hidden see07 C# 1 Feb 2nd, 2005 10:35 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:31 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC