×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Grid Coloring Problem
2

Grid Coloring Problem

Grid Coloring Problem

(OP)
I have a working coloring scheme using DynamicBackColor of Grid columns, which works, but the dyanmicbackcolor is overridden by highlighting the active row when I set Grid.AllowCellSelection = .F.

A right-click on a cell increments a numeric field which in turn changes the backcolor, as that number references a color in the dynamicbackcolor expression. All that works, but the color change can only be seen when I move to another row, that's what makes this highlighting unfortunate.

I have highlight=.f., highlightrow=.f., and I read in "What's new in 8" that it's the AlllowCellSelection=.F. which turns on this highlighting and I can confirm setting that .t. solves the coloring problem, but I get the text cursor into a field that's not intended to be modified.

To solve that I could set the textbox to readony, but when you do that and then type text while such a grid cell has focus you get a sound, I also don't wnat the text cursor to show there. If I prevent the cell to get focus at all with RETURN .F. from When event, that's fine again, but then I can't cuase a change of the numeric field and the backcolor with a right-click as the RighClick() event isn't triggered in that case.

This all is a cascade of problems to which I don't see a nice simple solution, but parhaps one of you?

In short what I need is a display only grid that when I click on a cell should change backcolor without a textcursor appearing.

Bye, Olaf

Olaf Doschke Software Engineering
https://www.doschke.name

RE: Grid Coloring Problem

(OP)
I played with the grid and the only solution I found so far with AllowCellSelection = .F. is setting the HkghlightBackColor to EVALUATE(...DynamicBackColor), the only problem with that is the whole row is set to this color then, I'd like to have this with one column only. Notice I have Hightlight=.F. and HighlightRow=.F., it's AllowCellSelection=.F. causing a row highlight with the HighlightBackColor.

The problem is still not solved this way, only for the case of a single column grid, but that's not sufficient.

In the case of AllowCellSelection = .F. you also have other weird effects, the inner portion of the Text1 Grid Textbox will show the form color if you set Text1.BackStyle=0 (Transparent) besides the text cursor shows.

Any other ideas? Using another control in the columns, perhaps?

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: Grid Coloring Problem

2
Olaf,

Have you considered using a container instead of a textbox in the grid? I'm not sure if that will meet your needs, but I often find that using a container can solve a lot of problems relating to grid highlighting and insertion points.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: Grid Coloring Problem

Olaf,
I know this comment isn't helpful, but when I see you post a question like this I figure if you haven't figured it out, the world is about to end. :)
I haven't had this same issue, but I don't tend to make any of my grids editable either. So the cursor isn't allowed to appear because the cell can't be selected, only the row.
Sorry I don't have anything constructive to add.

Best Regards,
Scott
MSc ISM, MIET, MASHRAE, CDCP, CDCS, CDCE, CTDC, CTIA, ATS

"Everything should be made as simple as possible, and no simpler."hammer

RE: Grid Coloring Problem

(OP)
Well, thanks, Scott. I rarely need to ask, but this seemed like doable and I think Mike has the best point about using something else but the Grids own Text1 Textbox.

Thanks for the idea, Mike, I might not even need a container, I have the feeling even a Textbox I add into a grid column and use with sparse=.f. would behave differently than the native Grid Text1 textbox.

I haven't tried yet, but knowing how you can use an image and its BackStyle property with a BackStyle_access method I think the container idea will work and I have a pseudo-event to take care of the container back color or anything else I need to modify per row. I may even use an image control to render text, that would even allow merging two rows visually by creating two half images and center text vertically in two grid rows. The upper cell image having the upper half of the text at its bottom and the lower cell image havíng the lower half of the text at its top. Turn off grid lines and this might look seamless.

First just trying another textbox or container. Let me see how that works.

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: Grid Coloring Problem

Let us know how you get on, Olaf. It's an interesting problem.

Using the BackStyle_access event should work with containers, but you might need to experiment to get the exact effect you need.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: Grid Coloring Problem

(OP)
Just using a native container and setting borderwidth=0 I'm almost there, the container.backcolor indeed is driven by the column dynamicbackcolor without any further intervention. IÄm not finished, but It clearly solves the highlightcolor overriding problem.

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: Grid Coloring Problem

Olaf,
when you have figured this thing out, I am very intesting to a) see it work an b) read the coding. Maybe you can than post a working example?
Thanks,
Koen

RE: Grid Coloring Problem

(OP)
I'm not finished yet, but the major ingredients are:

a) A class I called "containertextbox" based on a container that's hosting a textbox.
b) A grid with AllowCellSelection = Hightlight = HiglightRow = .F., HighlightStyle=0. You can set HighlightBackColor as you like, this will affect normal textboxes, but not this container
c) Container Backstyle=1 (opaque), Text1 textbox also, turning anything transparant puts you back to the problem of HighlightColor overriding the DynamicBackcolor
d) Backstyle_Access method (go into property editor and check the Assign checkbox to get this method created). With code:

CODE --> container.backstyle_access

This.BackColor = Evaluate(This.Parent.DynamicBackColor)
This.Text1.BackColor = This.BackColor
This.Text1.Value = Evaluate(This.Parent.ControlSource)
RETURN THIS.BackStyle 
e) Even though the Grid.AllowCellSelection = .F. disallows cells to get focussed, put RETURN .F. into the containertextbox.Text1.When() event.

The Parent is the Column into which you put this containertextbox class.

This still lacks some features, the container adapts to the grid cell also if you make the grid column and row resizable, but the resize event of the container does not occur, Seems solvable when you bind to either column resize or column.width and grid.rowheight properties. If you sync the text1 size with the cell size you might not even need to set the container.BackColor as the textbox will have full cell size, I did not have the time to try this part, but the major need of the container is its backstyle property. It's a known solution for the image control to change the picture on the fly when the grid draws itself it accesses backstyle of any control having a backstyle property and that's where you can do things that will be rendered afterward.

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: Grid Coloring Problem

Hi guys

Late to the party as always.... but is this similar to the issue i had in this thread?

thread184-1743972: Grid Row Highlighting...

Neil

I like work. It fascinates me. I can sit and look at it for hours...

RE: Grid Coloring Problem

(OP)
Yes, and I also already mentioned in my second post, the solution you found would work for a single column grid without other columns getting the same DynamicBackColor via HightlightBackColor.

It doesn't fit my needs and in general, if you have multiple columns with DynamicBackColors that will also not work with the AfterRowColChange "fix". One problem of the textbox in a container solution is, the textbox can't do all alignments the grid textbox can do. That means you can't vertically center text, but you can change the textbox top position. Besides, there are more dynamic properties you'd like to set in the TextBox of the Container besides the BackColor.

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: Grid Coloring Problem

Hi Olaf

It was for a multiple column grid (so I might have done more to it) - but for the life of me I can't find where I implemented it now to find more detail of what I was trying to achieve overall back then.

Anyway, looks like you have a better solution :)

Neil

I like work. It fascinates me. I can sit and look at it for hours...

RE: Grid Coloring Problem

(OP)
Just to be clear, of course setting the HighlightBackColor to the DynamicBackColor works for multiple column grids for all the row, but I want the other columns to have other colors or stay white or get the usual highlighting, just a single column should keep it dynamic color, as RightClick is used to change it and the user should see the effect they made on this cell immediately, before moving focus to another row or elsewhere. The color denotes a status for that cell only, not for the whole row. That's why I said I could only use it that way in a single column grid.

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close