addimage trouble

Discussion in 'Questions (Windows Mobile)' started by Cableguy, May 8, 2007.

  1. Cableguy

    Cableguy Expert Licensed User

    Hi,
    I'm tryingf to add an image in rumtime, but am getting sintax error...

    here the line thath error out

    addimage(control("panel"&NumbPanel+1),"icon",180,0,20,20)


    "Panel"&NumbPanel is a runtime created panel

    if i replace "Panel"&NumbPanel by panel2, wich i know is created, it works...
     
  2. RandomCoder

    RandomCoder Well-Known Member Licensed User

    I'd suggest placing MsgBox("panel"&NumbPanel+1) prior to your line that faults so that you can see which control is actually being used. It could be that you don't have the values you think you do.

    Regards,
    RandomCoder
     
  3. Cableguy

    Cableguy Expert Licensed User

    HI,

    Thanks RandomCoder, Ialready thought of that, and I can't see the error...

    The entire sub is as follows

    Sub Button1_Click
    'adds a first panel
    addpanel(form1,"panel"&NumbPanel,50,50,150,100)
    control("panel"&NumbPanel).color=csilver
    'adds a panel within the previous panel
    addpanel(form1,"panel"&NumbPanel+1,50,50,150,20)
    control("panel"&NumbPanel+1).color=cblue
    'necessary to bring the correct panel to front
    control("panel"&NumbPanel).BringToFront
    control("panel"&NumbPanel+1).BringToFront
    'ads an image to the second panel
    addimage(panel2,"icon",130,0,20,20)
    control("icon").image="close.png"
    control("icon").BringToFront
    End Sub
     
  4. RandomCoder

    RandomCoder Well-Known Member Licensed User

    I could be way off the mark here but if NumbPanel hasn't beeb assigned a value then it is set to zero. Therefore NumbPanel+1 is equal to 1 not 2.
    But you say that it works with the message box present but errors when its removed. That makes me think that its a timing issue?

    Regards,
    RandomCoder
     
  5. Erel

    Erel Administrator Staff Member Licensed User

    Until the next version you can't use a string or a variable as the parent control.
    You must write: AddImage (Panel1,...
     
  6. Cableguy

    Cableguy Expert Licensed User

    thanks Erel, I was starting to go cuco....
     
Loading...