Alternative background colour in gridview component
Posted
#1
(In Topic #576)
Regular

Posted
Regular

01McAc said
The Gridview component seems to have just one background colour for all rows in the grid….
GridView formatting is quite flexible…
Posted
Guru

Code (gambas)
- Setupform
- DecorateGridview
- With Gridview1
- .[iRow, iCol].Text = "Hello"
- .[iRow, iCol].Alignment = Align.Center
- .[iRow, iCol].Background = Rand(0, 7000000)
- .[iRow, iCol].Foreground = Rand(9000000, 16000000)
- .[iRow, iCol].Border = Border("margin:1;width:1;left-style:none;left-margin:0;left-width:0;top-right-radius:5;color:red")
- Gridview1.Columns.Width = -1
- .Height = 387
- .Width = 500
- .Arrangement = Arrange.Vertical
- .Padding = 5
- .Columns.Count = 8
- .Rows.Count = 17
<IMG src="https://www.cogier.com/gambas/GridColours.png">
</IMG>
Posted
Regular

cogier said
…Run this code in a Graphical Application…
Charlie, you forgot the Border variables!
Posted
Guru

Charlie, you forgot the Border variables!
Sorry Steve. Now corrected, see my last post.
<IMG src="https://www.cogier.com/gambas/GridColours1.png">
</IMG>
Posted
Regular

In any case it is not that colourful like your grid!
Posted
Guru

01McAc said
Thanks. The code works very well- but odd somehow as it doesn't work with any colour. I did try all the time with the wrong colours. Perhaps it is related with the dark mode settings on my desktop.
In any case it is not that colourful like your grid!
If you.post your code we could see if it's your code or not.
Your theme should make no difference.
Other configs might.
Like if using gtk or qt or some less advanced desktops using an old gambas. Various things.
Post your failing code here.
Posted
Regular

BruceSteers said
Post your failing code here.
Will do next time. I deleted already the failing code. I noticed btw that the gridview component is extremely fast when data are populated into the grid.
Posted
Guru

01McAc said
BruceSteers said
Post your failing code here.
Will do next time. I deleted already the failing code. I noticed btw that the gridview component is extremely fast when data are populated into the grid.
Well the code Cogier posted should work okay for you and show all you need to know about setting individual colours of your choice to each cell.
GridView is my favourite lister , If i need any sort of list in my apps i usually go for a GridView
1 guest and 0 members have just viewed this.



