[Gambas-user] make Label background from Database field
Doriano Blengino
doriano.blengino at ...1909...
Sun Oct 18 19:07:08 CEST 2009
Benoît Minisini ha scritto:
>> I get error:
>> "Result is not available"
>> at line:
>> "change_bgcolor("Label" & rsThesi!thesi)"
>>
>> of the code:
>>
>> PUBLIC SUB Form_Open()
>> DIM i AS Integer
>> DIM rsThesi AS Result
>> MODMain.Connect()
>> rsThesi = MODMain.$Con.exec("select * from egrafes where elenchosAnax =
>> 0")
>> rsThesi.MoveFirst
>> WHILE rsThesi.Index < rsThesi.Count
>> change_bgcolor("Label" & rsThesi!thesi)
>> rsThesi.MoveNext
>> WEND
>> MODMain.$Con.Commit()
>> END
>>
>> SUB change_bgcolor(labelname AS String)
>> DIM alabel AS Object '
>> FOR EACH alabel IN Form1.Children
>> IF alabel.name = labelname THEN
>> alabel.background = color.red
>> END IF
>> NEXT
>> END
>>
>>
>
> Hi, Vassili.
>
> I need your full project source and a SQL dump of your database, and which
> database backend you are using.
>
> And change_bgcolor() can be written this way:
>
> SUB change_bgcolor(labelname AS String)
> Form1[labelName].Background = Color.Red
> END
>
Funny - the first thing I looked for in the docs was a function
returning a reference by control name. I took a look in qt.form, and I
missed it...
Good to know.
Regards,
--
Doriano Blengino
"Listen twice before you speak.
This is why we have two ears, but only one mouth."
More information about the User
mailing list