Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Style Property on Dynamic Buttons

Status
Not open for further replies.

sifitz

Programmer
Feb 27, 2002
47
GB
I am creating CommandButtons on the fly in my VB code and I am setting the properties when the code creates each button. I want to assign pictures to the buttons (which requires the Style to be set to Graphical (1): the default is Standard (0) ).

So I need to set the Style Property, however, it is read-only at runtime. Is there some way of changing this?

Here is the code I am using
Code:
Dim strIndex = 0
    Set cmdButton = Controls.Add("VB.Commandbutton", "cmdButton" + strIndex, picMain)
   
    With cmdButton
        '.Style = 1
        ' Brings up "Can't assign to read-only property
 
        .Left = intLeft
        .Top = intTop
        .Picture = picHidden.Picture
        .Height = intButtonDim
        .Width = intButtonDim
        .Tag = strIndex
        .Visible = True
    End With

Thanks

Si Fitz
 
Just a simple cheat but if you make one control array for a non graphical command button and an control array for a graphical command button both with visible property set to false at design time you could add as many of each as you want at design time. Might help you out. Anything is possible, the problem is I only have one lifetime.[thumbsup2]
 
Just a simple cheat but if you make one control array for a non graphical command button and an control array for a graphical command button both with visible property set to false at design time you could add as many of each as you want at runtime. Might help you out. Anything is possible, the problem is I only have one lifetime.[thumbsup2]
 
sorry about the dups I tried to catch as error Anything is possible, the problem is I only have one lifetime.[thumbsup2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top