Results 1 to 4 of 4

Thread: [RESOLVED] Accessing label property in controls collection

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2007
    Posts
    165

    Resolved [RESOLVED] Accessing label property in controls collection

    Was dynamically adding a row of buttons each with label beneath in VB6 using control arrays. No arrays in VB.net, so it seemed a neat approach just to add direct to the controls collection, eg.

    For cnt = 1 To NumButt
    .Controls.Add(New Button) : cptr = cptr + 1
    With .Controls(cptr)
    .Width = bwidth
    .Height = bheight
    .left = etc etc
    End With
    Next cnt
    etc etc, similar code to add NumButt labels

    This seems pretty neat and works well, I can also set text and background images. Unfortunately, in just one case I need to set TextAlign of a label and it seems that one can only access those properties that are common to all controls in the controls collection, I can't see how to access those specific to a label, even though I can see in quickwatch that it is a label.

    Is there a way of doing it or do I have to rethink the entire approach?

    Alternatively, any way of ensuring all labels get created with TextAlign of MiddleCenter by default or better still copy all properties from an existing control?

    Cheers for any answers.
    Last edited by xoggoth; May 30th, 2007 at 11:37 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width