|
-
Sep 21st, 2010, 01:45 AM
#1
Thread Starter
Junior Member
[RESOLVED] Shapes
Hello all,
Is it possible to loop all rectangle shapes that are on form? I did something like that with textboxes.
Code:
Dim ctrl As Control
For Each ctrl In Me.Controls
If TypeOf ctlr Is TextBox
Some code here
End If
Next
-
Sep 21st, 2010, 02:03 AM
#2
Re: Shapes
Strictly speaking, those rectangles aren't actually controls. It's a little more complex than that. Each shape is actually a component. As far as I'm aware, there's only ever one control, i.e. a ShapeContainer, added to the form, no matter how many shapes you add.
vb.net Code:
For Each sc In Me.Controls.OfType(Of ShapeContainer)() For Each rs In sc.Shapes.OfType(Of RectangleShape)() MessageBox.Show(rs.Bounds.ToString(), rs.Name) Next Next
Note that you can view that hierarchy in the Document Outline window (Ctrl+Alt+T).
-
Sep 21st, 2010, 02:19 AM
#3
Thread Starter
Junior Member
Re: Shapes
Thank you very much for so quick respond. Works as charm!
-
Sep 21st, 2010, 08:26 AM
#4
Thread Starter
Junior Member
Re: [RESOLVED] Shapes
One more question. Is it possible to add tooltip for shape as for button?
Code:
ToolTip1.SetToolTip(Button1, "Some text")
-
Sep 21st, 2010, 06:24 PM
#5
Re: [RESOLVED] Shapes
As I said, a shape is not a control. You can only display ToolTips on controls, so no.
That said, you could display a ToolTip manually on the ShapeContainer, which is a control. You could handle the MouseHover event of the ShapeContainer, determine if the cursor is over a shape and, if it is, call Show on a ToolTip and specify the ShapeContainer as the control and the appropriate offset for the shape.
-
Sep 22nd, 2010, 03:54 AM
#6
Thread Starter
Junior Member
Re: [RESOLVED] Shapes
Thanks again, i will try that.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|