[Gambas-user] make Label background from Database field
Dimitris Anogiatis
dosida at ...626...
Fri Oct 16 23:48:10 CEST 2009
Vassili,
you might also want to take a look at
The Gridview control
http://www.gambasdoc.org/help/comp/gb.qt/gridview
and the Tableview control
http://www.gambasdoc.org/help/comp/gb.form/tableview
perhaps one of those two is a better approach than manipulating individual
labels
If you still want to experiment with your original label approach then this
might help
PUBLIC SUB Form_Open()
DIM i AS Integer
DIM rsThesi AS Result
DIM iD AS Long
MODMain.Connect()
rsThesi = MODMain.$Con.exec("select * from egrafes where elenchosAnax =
0")
'Move rsThesi to the first position
rsThesi.MoveFirst
WHILE rsThesi.Index < rsThesi.Count
SELECT CASE rsThesi!thesi
CASE 1
Label1.Background = Color.Red
CASE 2
Label2.Background = Color.Red
CASE 3
Label3.Background = Color.Red
..........................etc up to Label100
END SELECT
'Move rsThesi to the next record
rsThesi.MoveNext
WEND
END
your previous code didn't work because you weren't moving through rsThesi's
records
one by one, you only checked the first one. this code should work...
if I may add my 2 cents worth of programming wisdom, 100 labels can easily
be replaced
by a gridview and it would be a bit more visually appealing to the end user
but it's up to you
and what works best for you.
I hope this helps
Keep up the good work
Regards
Dimitris
On Fri, Oct 16, 2009 at 12:11 PM, Vassilis K <vkan53 at ...2300...> wrote:
>
> Since I did not want to make labels on run time, I got a solution to show
> red
> color as following:
>
> PUBLIC SUB Form_Open()
> DIM i AS Integer
> DIM rsThesi AS Result
> DIM iD AS Long
> MODMain.Connect()
> rsThesi = MODMain.$Con.exec("select * from egrafes where elenchosAnax =
> 0")
> WHILE iD < rsThesi.Count
> SELECT CASE rsThesi!thesi
> CASE 1
> Label1.Background = Color.Red
> CASE 2
> Label2.Background = Color.Red
> CASE 3
> Label3.Background = Color.Red
> ..........................etc up to Label100
> END SELECT
> INC iD
> WEND
> MODMain.$Con.Commit()
> END
>
> This solution shows only the first found Label (or rsThesi.thesi value) as
> Red
> the others remain uncolored even though they have number values as 10, 25
> etc.
> I thing there is an error on the loop and it stops at the first found
> number
> of the field rsThesi!thesi.
> Any suggestions?
>
>
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay
> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
> http://p.sf.net/sfu/devconference
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
More information about the User
mailing list