[Gambas-user] Add objects to a scrollview

Timothy Marshal-Nichols timothy.marshal-nichols at ...247...
Fri Sep 8 19:16:02 CEST 2006


> -----Original Message-----
> From: gambas-user-bounces at lists.sourceforge.net
> [mailto:gambas-user-bounces at lists.sourceforge.net]On Behalf Of sbungay
> Sent: Friday, 08 September 2006 17:38
> To: mailing list for gambas users
> Subject: Re: [Gambas-user] Add objects to a scrollview
>
>
> Timothy Marshal-Nichols wrote:
> >>-----Original Message-----
> >>From: gambas-user-bounces at lists.sourceforge.net
> >>[mailto:gambas-user-bounces at lists.sourceforge.net]On Behalf Of rolf
> >>Sent: Friday, 08 September 2006 12:44
> >>To: mailing list for gambas users
> >>Subject: [Gambas-user] Add objects to a scrollview
> >>
> >>
> >>Hi everybody out there,
> >>
> >>still fighting with objects I would like to ask if someone can
> >>give me a hint,
> >>how to add objects like comboxes, textlabels... to a scrollview
> >>dynamically
> >>at runtime. BTW the scrollview itself is element of a tabstrip.
> >>
> >>Many thanks for your suggestions
> >>Rolf
> >>
> >
> >
> > Take a look at the example at
> > http://www.linuxbasic.net/index.php?topic=117.0
> >
> > This example uses a Form as the parent of the dynamic controls.
> However you
> > can use any container - even throw caution to the wind and use
> a ScrollView.
> > You would change the line:
> >
> > 	b = NEW Button(ME) AS "KeyButton"
> >
> > to your ScrollViewName:
> >
> > 	b = NEW Button(ScrollViewName) AS "KeyButton"
> >
> >
> >
> > Thanks
> >
> > 8-{)} Timothy Marshal-Nichols
> > <mailto: timothy.marshal-nichols at ...247...>
> >
> >
> >
>    This is good stuff. Lets say we want to dynamically instantiate
> buttons in an hpanel and then assign pictures to the buttons surfaces
> and values to their tags. I did this..
>
> DIM bh as Button
>
> bh - NEW Button(hpanel1) AS "Button" & CSTR(hpanel1.children.count)
     = ???

I would not have a separate "button tag" for each button in the AS clause.
How could you handle the button click event? In the example we set the
button tag property to unique value. Then use LAST.Tag object to see which
button was pressed. Look at example to see how we handle the click event.

> WAIT

Do not think there is any need for the wait.

> bh.picture = bh.picture.load("MyImage.png")

or plain:

  bh.picture = Picture["MyImage.png"]

>
>   And it creates the button OK, but gives me a NULL OBJECT error when it
> executes the picture assignment. Shouldn't 'bh' be a handle to the newly
> instantiated button?
>
> Steve.
>
Thanks

8-{)} Timothy Marshal-Nichols
<mailto: timothy.marshal-nichols at ...247...>






More information about the User mailing list