Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cell colours ina grid

Status
Not open for further replies.

Bryan - Gendev

Programmer
Jan 9, 2011
408
AU
As mentioned before my grid is produced programmatically.
Of the 16 or so fields presented only 6 are required/able to be modified.
I would like these fields to be coloured differently to all the rest.
Can you suggest the code like
.BackColor= Rgb(255,255,255)
.ForeColor = Rgb(255,0,0)

for an attractive scheme - say white on green?

GenDev
 
Well, you're almost spot on, you just have to set the colors of the columns. I'd not change forecolor, keep that at black, that's only the text color.
Change the backcolor from white to RGB(200,255,200), for example, a light green, for the modifiable fields.

Chriss
 
Chris,
Thanks for that...

Interestingly the color appears in the cells only in a row with no entries - not in a row with my populated fields.
In general my settings for say a Memo field are

WITH .Column6 && caption
.ControlSource = 'EDITING_.CAPTION'
.Header1.Caption= 'Caption'
.AddObject("mycmd","gs_editcap")
.Sparse = .F.
.CurrentControl = "mycmd"
.ReadOnly = .F.
.Width = 60
.BackColor= RGB(200,255,200)
ENDWITH
Is it possible to color the populated cells ?


GenDev
 
The coloring of the columns also appears in populated cells, unless the currentcontrol overrides that.

You set the current control to a command button, it seems to me judging by the class name "mycmd". The name "gridmemocmd" would be more suited for the use case, but that aside. Well, buttons are opaque and so the column color doesn't show through. Also, command buttons are having standard windows colors, usually grey tones. You can only override button colors when you turn their theme property off, so change the mycmd control definition, both for setting command.themes=.f. and setting its backcolor.

I know you use such button classes for memo fields, but I also suggested to not override the usual column control, a text box for other field types and program the interactivechange event for them, the backcolor for such columns should show, unless you set column.sparse=.f. and therefore again override the use of the columns' textbox as the cell control.

Chriss
 
I overlooked the classname is what you posted earlier:
Code:
Define Class gs_captionedit As TextBox
...

Well, a textbox by default is opaque. It's not a button, though. It is enough to set its backcolor, but as it's opaque and you use sparse=.f., the column backcolor does not show through the textbox backcolor. So add a line setting the backcolor in the textbox class definition, also set the borderstyle to 0 to have no artifacts of a textbox border (no matter if flat or 3d style) within the grid cell.

Chriss
 
As you're choosing colors, keep in mind that something like 10% of people have some form of colorblindness, so you need to make sure that those people will be able to see the contrast in whatever you choose. This seems to have some advice for that:
I used to recommend basing such things on the user's Windows color settings, but they've made it a lot harder both to get that info programmatically, and for users to change it as they'd like.

Tamar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top