|
-
February 19th, 1999, 07:46 AM
#1
Control arrays
I have a problem with control arrays, which I would be interested to see if anyone has an answer for.
If I have a control array of 'UIElement' controls I can access their individual positions as follows:
UIElement(0).Left
UIElement(0).Top
etc.
However I can't do the following:
dim uie as UIElement
set uie = UIElement(0)
and then access the position of that UIElement:
uie.left
uie.top
this will cause an error 'Method or data member not found' because the individual UIElement no longer has these properties. The only way to access these (and other) properties is through the control array.
I have two questions, one is there a workaround for this? And two Don't you think this is a daft way for VB to behave?
Rupert
-
February 19th, 1999, 08:20 AM
#2
Re: Control arrays
Hi
I'm not sure if I understand your problem, because I cannot reproduce your problem, but ...
>dim uie as UIElement
>set uie = UIElement(0)
This would imply to me that you have a control array called UIElement - therefore you cannot define a variable as UIElement.
I tried this with a control array of labels - Create a form (form1), add a label (label1) - create 4 more labels from label1 (ie. index 0,1,2,3,4)
Dim lbl As Label
Set lbl = Label1(2)
lbl.Left = lbl.Left * 2
This code worked fine.
You can always reference an element in a control array using 'With', eg:
With UIElement(0)
.Left = Whatever
.Right = Whatever
.DoSomeStuff
End With
Regards
Chris Eastwood
CodeGuru - the website for developers
http://www.codeguru.com/vb
-
February 19th, 1999, 09:32 AM
#3
Re: Control arrays
Yes, you're right, this does work ok with intrinsic VB controls. I am trying to do it with UserControls though and for these, it doesn't work.
-
February 19th, 1999, 09:58 AM
#4
Re: Control arrays
ahhh...
How about :
Dim ctl As Control
Set ctl = UIElement(0)
ctl.Left = xxxxx
Regards
Chris Eastwood
CodeGuru - the website for developers
http://www.codeguru.com/vb
-
March 1st, 1999, 01:30 AM
#5
Re: Control arrays
Better if you try vbControlExtender instead of control as it can give you events also, if you need in future.
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
|