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

how to use setall for columns in a grid 1

Status
Not open for further replies.

sncheong

Programmer
Jan 18, 2001
47
NZ
my grid has 35 columns. i rename the last 31 column-headers as 1,2,3 etc respectively so that i can change its backcolor to rgb(0,0,255) if the header is a odd number. how do i use setall to solve the problem? ta
 
HI,

You have 35 columns. The first 4 columns have some Back color and you have set their captions. Now the next i.e. 5th column onwards, the caption is 1, 2, 3 etc and the color of odd captioned header columns to be set differently.

********************************************************
** In the init event of the grid, you can add the code..
WITH This
i = 0
FOR EACH oColumn IN .COLUMNS
I=I+1
IF I > 4
oColumn.Header1.Caption = ALLTRIM(STR(i))
IF MOD(i,2) > 0 && Odd numbers
oColumn.DynamicBackColor = "RGB(0,0,255)"
ENDIF
ENDIF
ENDFOR
ENDWITH
*************************************************

:) ramani :)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
HI!
I think may be it:
FOR n=11 TO 35
IF !(MOD(n,2)=0)
ZM_I='ThisForm.Grid1.Column'+ALLTRIM(STR(n))
ZM_I=ZM_I+'.Text1.BackColor=rgb(0,0,255)'
ENDIF
ENDFOR
Monika Kind regards to you all from Warsaw !!!!!
 
My mistakes:

FOR n=11 TO 35
IF !(MOD(n,2)=0)
ZM_I='ThisForm.Grid1.Column'+ALLTRIM(STR(n))
ZM_I=ZM_I+'.Text1.DynamicBackColor="rgb(0,0,255)"'
&ZM_I
ENDIF
ENDFOR

SORRY
MONIKA
Kind regards to you all from Warsaw !!!!!
 
sorry guys, both didn't work. what i wanted is only the header.backcolor changes to rgb(0,0,255) not the column.dynamicbackcolor or the text.backcolor. i was trying to adapt this.setall('backcolor',rgb(0,0,255), 'header') but couldn't isolate the odd number headers. would appreciate your further thoughts/suggestions. ta
 


sorry guys, both didn't work. what i wanted is only the header.backcolor changes to rgb(0,0,255) not the column.dynamicbackcolor or the text.backcolor. i was trying to adapt this.setall('backcolor',rgb(0,0,255), 'header') but couldn't isolate the odd number headers. would appreciate your further thoughts/suggestions. ta

Sorry, no dynamic color of anykind in the header. You'll have to set it by hand.
Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first
 
hi mike
actually, i wanted the column(n).header1.backcolor only.
 
sncheong

Here is a way to do what you need:
[ol][li]Create a method in your form (call it IsEven).That will check to see whether your column number is even or odd.
Code:
lParameters nInteger
Return Not Bittest(nInteger, 0)
[/li]
[li]In the init of your grid put this code:
Code:
local oObj
With This
  For n = 1 To 10
     oOBj = ".column"+Alltrim(Str(n))+"."
     &oOBj.header1.BackColor=Iif(Thisform.isEven(n),Rgb(192,192,192),Rgb(100,100,100))
   Endfor
Endwith
[/i][/ol]


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first
 
sncheong

The above code should be changed to 35 if you have 35 columns

local oObj
With This
For n = 1 To 35 && If you have 35 columns
oOBj = ".column"+Alltrim(Str(n))+"."
&oOBj.header1.BackColor=Iif(Thisform.isEven(n),Rgb(192,192,192),Rgb(100,100,100))
Endfor
Endwith

Monikai

ZM_I=ZM_I+'.Text1.DynamicBackColor="rgb(0,0,255)"'

Texboxes don't have a dynamicBackColor property



Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first
 
mike, it works! i am now expanding your codes for weekends too. it also works if i drop +"." from line4 and put a space between &oOBj and header1.BackColor in line5. why is this possible?

as i am checking the last 31 columns, i amended n=5 to 35 instead.

many tks.[2thumbsup]
 

local oObj
With This
For n = 5 To .columnCount
oOBj = ".column"+Alltrim(Str(n))
&oOBj .header1.BackColor=Iif(Thisform.isEven(n),Rgb(192,192,192),Rgb(100,100,100))
Endfor
Endwith

You can use the .columncount also that way you don't have recode if you add a column

put a space between &oOBj and header1.BackColor in line5. why is this possible?

I don't know, I was also taught to do it the way I proposed.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first
 
tks again for your tips, mike. yes, i quite agree that your way of handling the "." is straight-forward. i shall keep that it in mind. cheers.
 
Mike!
Yes, it haven't "dynamic". Sorry for mistake !!!
Monika Kind regards to you all from Warsaw !!!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top