By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,164 Members | 1,019 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,164 IT Pros & Developers. It's quick & easy.

enumerate selected controls in design view of a form

P: n/a
I am working on a project that requires me to be able to enumerate
through all the controls that may be selected (ie: showing their
selection handles) in a forms design view window. I have managed to
capture the active form and can iterate through all the controls on the
form but I want to be able to minimise the list to only the controls
with the selection handles are identified.

Any help would be greatly appreciated.
Greg J

Apr 28 '06 #1
Share this Question
Share on Google+
1 Reply


ADezii
Expert 5K+
P: 8,669
I am working on a project that requires me to be able to enumerate
through all the controls that may be selected (ie: showing their
selection handles) in a forms design view window. I have managed to
capture the active form and can iterate through all the controls on the
form but I want to be able to minimise the list to only the controls
with the selection handles are identified.

Any help would be greatly appreciated.


Greg J
The InSelection Property should be exactly what you are looking for:

'To determine the Selection status of a Control on a Form in Design View,
'execute the following code from the Debug Window (It can easily be
'modified to adapt to your specific needs)

? IsControlSelected (Forms!Customers, "CompanyName")

Function IsControlSelected(frm As Form, strControlName As String) As Integer
Dim intI As Integer, ctl As Control
If frm.CurrentView <> 0 Then
' Form is not in Design view.
Exit Function
Else
For intI = 0 To frm.Count - 1
Set ctl = frm(intI)
If ctl.InSelection = True Then
' Is desired control selected?
If UCase(ctl.Name) = UCase(strControlName) Then
IsControlSelected = True
Exit Function
End If
Else
IsControlSelected = False
End If
Next intI
End If
End Function

'Hope this works for you
Apr 28 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.