![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Dec 2007
Posts: 2
Rep Power: 0
![]() |
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 |
|
|
|
|
|
#2 |
|
Hobbyist Programmer
Join Date: Dec 2005
Posts: 118
Rep Power: 0
![]() |
Re: Select a control by name
CheckBox1.SetFocus; |
|
|
|
|
|
#3 | |
|
Newbie
Join Date: Dec 2007
Posts: 2
Rep Power: 0
![]() |
Re: Select a control by name
Quote:
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 |
|
|
|
|
|
|
#4 |
|
Programming Guru
![]() Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,223
Rep Power: 5
![]() |
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.
|
|
|
|
|
|
#5 |
|
Hobbyist Programmer
Join Date: Dec 2005
Posts: 118
Rep Power: 0
![]() |
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. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
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 |