[Gambas-user] How to address a text label created by code?

M0E Lnx m0e.lnx at ...626...
Thu Jan 24 21:57:17 CET 2008


I've been designing forms for a while now, and this is my second
gambas application. In all other forms, I've always drawn the controls
into the form, assign the properties, and handle events... all from
the GUI.
I decided to try to create a function to dynamically create
components. The idea is to allow this application to be more
expandable without modifying much of the code, so here is what I did.

I have a form, in ther form there is a scrollview and an IconView
I place some text labels on the scrollview. This gets triggered in the
forms' Load event

This function creates a Tex label for every directory in my $HOME dir.
Each resulting text label enherit's it's own directory name.

kinda like this

PUBLIC SUB Form_Open()
dim sDir as string
dim tDirTL as TextLabel
dim iY as integer

FOR EACH sDir in RDir("/home/vluser")
IF ISDIR("/home/vluser" &/ sDir) then
tDirTL = new TextLabel(ME.Scrollview1) as "tDirLabel"

WITH tDirTL
.text = sDir
.heigh = 32
.width = 100
.X = Me.Scrollview1.X + 4
.Y = iY + 32
END WITH
end if
iY = iY + 32
NEXT
END

I can handle the events using LAST

PUBLIC SUB tDirTL_Mousedown()
Message.Info(LAST.Text & " was clicked")
END

Now, I want the label I click to turn it's label into Bold Lettering.
I can do that using the font.bold = true property in the above SUB

And here is my dilemma.
I need every other label's Text to remain in plain lettering, and the
Font.Bold to be applied only to the last label I click on.

I've tried to set the font.bold = false but I can't find a way to
address the other text labels...

Using Gambas2-2.0.0. Any help is appreciated.




More information about the User mailing list