In this tutorial we will learn how to add a nice looking Listbox row info effect that can be found for example in Apple Mail (new messages in Inbox) or in Chronories application (number of search results). Watch it, learn it, enjoy it!
Simply add a Listbox Control to Window1 and then in Listbox1 Sub Open () enter some code… Set also the DefaultRowHeight Property to 24.
1 2 3 4 5 | Listbox1.AddRow("Folders") Listbox1.AddRow("Files") Listbox1.AddRow("Pictures") Listbox1.AddRow("Movies") Listbox1.AddRow("Music") |
At this part we will format the look of our data, and we will also add row info effect with some random numbers inside. Add this code to Listbox1 Function CellTextPaint ().
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | Dim r As New Random if column = 0 then g.DrawString (me.Cell(row, 0), x, 18, g.Width - x, true) //draw the Listbox1.AddRow("Folders") etc. end g.ForeColor = &cCDCDCD //change color to silver g.FillRoundRect(me.Width - 33, 3, 22,17, 15,15) //paint a round rectangle g.ForeColor = &cFDFFFB //change color to white g.Bold = true //bold on g.TextSize = 11 //change font size to 11 g.DrawString(Str(r.InRange(0,9)),me.Width - 26, 15, g.Width - x, true) //draw a String with random number return true |
Premium Members will get access to RBP file tomorrow.
If I already have the numbers of files on the 2nd column from a database, how could circle them, please?
Simply draw the 2nd column text.
g.DrawString(me.Cell(row, 2),me.Width – 26, 15, g.Width – x, true)
Hai … thanks for your tutorial, really good, simple and usefull.