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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Altering a MSFlexgrid Cell without cell getting focus 1

Status
Not open for further replies.

yacyac

Programmer
Jul 29, 2002
78
US
I am populating a msflexgrid either from a file or by user input. If the value in any row for column 5 is > 50 and < 200 then the cell backcolor for that cell is red else white.

Doing this is not an issue. The issue lies in that column 5 for any particular row may not get the focus. We have locks on certain columns depending on what is entered in earlier columns.

example: If inputing data and col 1 for a particular row is 1 then allow focus to coloumns 2, 3 and 7 of that row etc.

If input data for col 1 is 2 then allow focus to columns 2, 3 and 5

Problem is that if the user changes the value in column 1 from 2 to 1 and the value in column 5 had been 60 - the cellbackcolor of column 5 for the row is red. Since column 5 can not get the focus now - I can't change the cell back color

Is there anyway of changing a cells backcolor without activating cell enter?
 
A Seach on '.cellbackcolor' gives many results. thread222-789001 is an example. For one specific cell make sure that the .row (starting row) and .rowsel(finishing row) are the same and the .col (starting cell) and .colsel (finishing cell) are the same. this will narrow your range of cells to one cell.

zemp
 
All the methods I can find have cell entered firing. I need to be able to change a cell backcolor without cell entered firing?
 
One way is to use a modular boolean flag. Set it to true when you don't want to run the code in the enter cell event (before the code to change the cell back colour).
Code:
m_bolMyFlag =true
 ...code to change cell colour
m_bolMyFlag =false[code]
Then place this code as the first line of the enter cell event.
[code]If m_bolMyFlag then Exit Sub
This will then bypass any code. Might also be useful in the leave cell event. don't forget to reset the flag to false. May not be the cleanest solution but it works.

zemp
 
Thanks Zemp - that got me going in the right direction. i also had to add variables to get back to the col the program wanted to go to after I diverted it to col 5
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top