VFP9 kullaniyorsan icase() kullanabilirsin. Yoksa icice iif():
Visual Fox Pro
1
2
| thisform.myGrid.SetAll( "DynamicBackColor", ;
"(icase( alias.Field < 0, 0xFF, alias.Field > 0, 0x00FF00, 0xFF0000))" ) |
Visual Fox Pro
1
2
| thisform.myGrid.SetAll( "DynamicBackColor", ;
"(iif( alias.Field < 0, 0xFF, iif(alias.Field > 0, 0x00FF00, 0xFF0000)))" ) |
Bu iş kolay görünüyor, ancak senin şartın karmaşıklaştıkça bu icase(), iif() vs yazmak zorlaşıyor ve hata yapma şansı artıyor. Hatalı yazdıysan, VFP hata mesajı vermez ama renklendirmeyi de yapmaz.
O nedenle karmaşık ifadeleri oraya yazmak yerine, oraya cok basit bir ifade yazabilirsin:
Visual Fox Pro
1
| thisform.myGrid.SetAll( "DynamicBackColor", "(thisform.GridArkaRenk())" ) |
İhtiyacına gore o metoda parametre de gonderebilirsin ve SetAll'un cozemedigi durumlarda daha esnek kullanabilirsin.
Parametreli ve SetAll'un cevap olmadıgı durumlar icin ornek:
Visual Fox Pro
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
| Public oForm
oForm = Createobject("myForm")
oForm.Show()
Define Class myForm As Form
DataSession = 2
Height = 600
Width = 800
Add Object grid1 As Grid With ;
left=0,Width = 400,Height=600,RecordSource="ornekData"
Add Object grid2 As Grid With ;
left=400,Width = 400,Height=600,RecordSource="ornekData"
Procedure Load
Rand(-1)
Select ;
Int(Rand()*20) - 10 As sayi, ;
Company, ;
Country, ;
DATE(2006, Int(Rand()*11)+1, 1) As tarih ;
FROM (_samples+'data\customer') ;
INTO Cursor ornekData ;
nofilter
Endproc
Procedure grid1.Init
This.Columns(1).Width = 30
This.Columns(2).Width = 200
This.Columns(3).Width = 60
This.Columns(4).Width = 60
This.SetAll("DynamicBackColor", "(thisform.GridArkaRenkOrnek1( ornekData.Sayi ))")
Endproc
Procedure grid2.Init
This.Columns(1).Width = 30
This.Columns(2).Width = 200
This.Columns(3).Width = 60
This.Columns(4).Width = 60
Local ix
For ix = 1 To This.ColumnCount
With This.Columns(m.ix)
.DynamicBackColor = ;
"(thisform.GridArkaRenkOrnek2('" + .ControlSource +"'))"
Endwith
Endfor
Endproc
Procedure GridArkaRenkOrnek1(tnSayi)
Do Case
Case m.tnSayi > 0
Return 0x00FF00
Case m.tnSayi < 0
Return 0xFF
Otherwise
Return 0xFF0000
Endcase
Endproc
Procedure GridArkaRenkOrnek2(tcControlSource)
Local lcType, luValue
lcType = Type(m.tcControlSource)
If m.lcType != "G"
luValue = Evaluate(m.tcControlSource)
Endif
Do Case
Case m.lcType = "C"
* Degerin crc degerine gore renk
Return BITLSHIFT(VAL(SYS(2007,m.luValue)),8)
Case m.lcType = "D"
* 3 aylik donemlere gore renk
Do Case
Case Ceiling(Month(m.luValue)/3) = 1
Return 0xFFFF00
Case Ceiling(Month(m.luValue)/3) = 2
Return 0xFF00FF
Case Ceiling(Month(m.luValue)/3) = 3
Return 0x00FFFF
Otherwise
Return 0xC0C0C0
Endcase
Case m.lcType = "N"
Do Case
Case m.luValue > 0
Return 0x00FF00
Case m.luValue < 0
Return 0xFF
Otherwise
Return 0xFF0000
Endcase
Endcase
Return 0xFFFFFF
Endproc
Enddefine |
Son düzenleyen, cetinbasoz (23.09.2007 13:26:02)
Yen yaz 1907'ye yolla FB gelsin evinde yensin.
(sonra salaklar ciksin alin terine şike desin)