1 Son düzenleyen, bahattin (24.10.2007 14:04:57)

Konu: Grid sıralama ..

Merhaba ..
Önceki mesajlarda bu konuda bir kod gördüm ama onu kullanmak istemiyorum.
Önceden grid sütunlarını Wizard ile oluştururken her column.header.click ine aşağıdaki kodu yazıyordum. (biraz kaba bi kod ama ..)

şimdi grid i ,  sizlerden  öğrendiğim gibi grid.init de  düzenliyorum.

ben kolon sıralaması ile ilgili aşağıdaki kodu nereye yazmalıyım..

Şimdiden teşekkürler..
İyi Çalışmalar..

Visual Fox Pro
thisform.grid1.column1.header1.forecolor=RGB(0,0,0)

thisform.grid1.column2.header1.forecolor=RGB(0,0,0)
*thisform.grid1.column3.header1.forecolor=RGB(0,0,0)
thisform.grid1.column4.header1.forecolor=RGB(0,0,0)
thisform.grid1.column5.header1.forecolor=RGB(0,0,0)
thisform.grid1.column6.header1.forecolor=RGB(0,0,0)
thisform.grid1.column7.header1.forecolor=RGB(0,0,0)
thisform.grid1.column8.header1.forecolor=RGB(0,0,0)
 
SELECT cmv
local m.renk
do case
case thisform.grid1.column3.header1.forecolor=RGB(0,0,0)
m.renk=1
case thisform.grid1.column3.header1.forecolor=RGB(255,0,0)
m.renk=1
case thisform.grid1.column3.header1.forecolor=RGB(0,0,255)
m.renk=2
endcase
if m.renk=1
SET ORDER TO cvad ASCENDING
thisform.grid1.column3.header1.forecolor=RGB(0,0,255)
else
SET ORDER TO cvad descending
thisform.grid1.column3.header1.forecolor=RGB(255,0,0)
endif
GO TOP
THISFORM.Refresh
endwith

2

Re: Grid sıralama ..

sanırım bu biraz yardımcı olur.

Visual Fox Pro
Thisform.grid1.RecordSource = "doviz"

With Thisform.grid1
    .ReadOnly = .T.
    .DeleteMark = .F.
    .RecordMark = .F.
    .ColumnCount = 5
    .ScrollBars= 2
 
    .column1.ControlSource = "doviz.tarih"
    .column1.header1.Caption = "Tarih"
    .column1.Width = 100
 
    .column2.ControlSource = "doviz.adi"
    .column2.header1.Caption = "Adı"
    .column2.Width  = 60
 
    .column3.ControlSource = "doviz.aciklama"
    .column3.header1.Caption = "Açıklama"
    .column3.Width  = 75
 
    .column4.ControlSource = "doviz.kur"
    .column4.header1.Caption = "Kur"
    .column4.Width  = 60
 
    .column5.ControlSource = "doviz.id"
    .column5.header1.Caption = "id"
    .column5.Width  = 150
 
 
Endwith
Bilmediğin Neyse Yanıldığındır.

3

Re: Grid sıralama ..

& grid init

Visual Fox Pro
with this

    For i =1 To .ColumnCount
        With .Columns(i)
                        .header1.forecolor=RGB(0,0,0)
            .fontname=[Tahoma] &&column un tamami icin
            .fontsize=8
            .FontBold= .T.
            .Header1.FontName=[Tahoma]
        Endwith
    Endfor
endwith

&& yada

Visual Fox Pro
with this

    For Each oColumn In .Columns
                oColumn.header1.forecolor=RGB(0,0,0)
        .FontName=[Tahoma] &&column tamami icin
        .FontSize=8
        .FontBold=.T.
    Endfor
endwith

hangi kolonlarda siralatma yapmak istiyorsan sunu da yapabilirsin efektif bence

&& sıralatma yapmak istedigin gridin her column.header1 click eventina asagidaki kodu

Visual Fox Pro
LOCAL lnRecno

lnRecno = IIF(EOF() OR BOF(),1,RECNO())
TRY
    IF UPPER(JUSTSTEM(this.Picture))="UP"
        this.Picture = HOME(2)+"Solution\toledo\down.bmp"
        SET ORDER TO "ckodu" DESC && alan ismini kendine gore ayarla
                && this.parent.controlsource ta olabilir
        this.Parent.Parent.Refresh()
    ELSE
        this.Picture = HOME(2)+"Solution\Toledo\up.bmp"   
        SET ORDER TO "ckodu"
        this.Parent.Parent.Refresh()
    ENDIF
CATCH
FINALLY
    GO lnRecNo
ENDTRY


&& sıralatma yapmak istedigin gridin her column.header1 picture property sine

Visual Fox Pro
HOME(2)+"Solution\Toledo\up.bmp"

yazabilirsin

4

Re: Grid sıralama ..

Sayın Duyar ilginiz için teşekkürler..

benim grid in init i de sizin yazdığınız gibi zaten

oraya ilave aşağıdakini ekledim.
hata veriyor..


with thisform.grid1.column1.header1 .click
....
....yukarıdaki kod
....
endwith

5

Re: Grid sıralama ..

Soykan bey teşekkürler..
kısa yoldan kolonları bu şekilde formatlayabiliyoruz..bunu böyle değiştirim.
ama
thisform.grid1.column1.header1  e click lendiğnde olacakları nereye yazmalıyım.

with thisform.grid1.column1.header1 .click
....
endwith

kabul etmiyor..

iyi çalışmalar dilerim..

6

Re: Grid sıralama ..

Onceki mesaja ek yaparak ornek kod yazdim

7

Re: Grid sıralama ..

Soykan bey sizi   çok fazla meşgul etmek istemem ama..
ortada kolon ve header yok daha grid init de oluşturuyorum kolonları başlıkları
Şöyle..

grid init..

Visual Fox Pro
CREATE cursor cmv ;

(ctrh d(8),cgun n(3),cvad d(8),cksl c(5),cack c(41),cbrc n(15,2), calc n(15,2),cnum n(10))
 
local xctrh,xcgun,xcack,xcbrci,xcalc,xcksl,xcnum
*store 0 to xcbrci,xcalc
select crmvn
go top
select cmv
WITH thisform.grid1
*.WIDTH=500
.columncount=8
.deletemark=.f.
.scrollbars=2
.recordmark=.f.
.recordSource = ;
"cmv"
endwith
 
**kolon1 tarih
with thisform.grid1.column1
.width=70
thisform.grid1.column1.header1.caption='Tarih'
thisform.grid1.column1.header1.alignment=2
endwith
 
*!*    **kolon2 gün
with thisform.grid1.column2
.width=40
.format   ='###'
thisform.grid1.column2.header1.caption='Gün'
thisform.grid1.column2.header1.alignment=2
endwith
 
**kolon3 vade
with thisform.grid1.column3
.width=70
thisform.grid1.column3.header1.caption='Vade '
thisform.grid1.column3.header1.alignment=2
endwith
 
 
**kolon4 vade
with thisform.grid1.column4
.width=42
thisform.grid1.column4.header1.caption='Koşul '
thisform.grid1.column4.header1.alignment=2
endwith
 
**kolon5 vade
with thisform.grid1.column5
.width=295
thisform.grid1.column5.header1.caption='Açıklama'
thisform.grid1.column5.header1.alignment=2
endwith
 
**colon6  borç
with thisform.grid1.column6
.width=72
.inputmask='####,###.##'
.format   ='####,###.##'
endwith
thisform.grid1.column6.header1.caption=' Borç '
thisform.grid1.column6.header1.alignment=2
 
**colon7  alacak
with thisform.grid1.column7
.width=72
.inputmask='####,###.##'
.format   ='####,###.##'
endwith
thisform.grid1.column7.header1.caption=' Alacak '
thisform.grid1.column7.header1.alignment=2
 
 
**colon8  Belge no
with thisform.grid1.column8
.width=80
.inputmask='##########'
.format   ='##########'
endwith
 
thisform.grid1.column8.header1.caption=' Belge No '
thisform.grid1.column8.header1.alignment=2
go top
 
*This.SetAll("DynamicBackColor", "IIF(cmv.iz=1, RGB(0,0,160) , RGB(0,0,0))", "Column")
thisform.refresh()

bu kodla grid init de kolonlar oluştu.
şimdi

"thisform.grid1.column1.header1.click"  event inede ilk başta yazdığım kodu yada sizin verdiğiniz
sıralama kodunu yazacağım.
ama bunu nereye nasıl yazacağım.

grid de sütun yada başlık yok

teşekkür ederim

8

Re: Grid sıralama ..

Grid'in init'inde eklemiş olduğun column'ların header'ların click event'ini yazamazsın.
Event'leri tasarım sırasında yazabilirsin.

Senin gönderdiğin kod için ancak class yaparsan bu class'ı initte eklersen click'ler çalışır.

/o---------------------o\
     www.haser.com
\o---------------------o/

9

Re: Grid sıralama ..

Teşekkür ederim arkadaşlar.
bu konu beni aşar..
herkese iyi çalışmalar dilerim.

10

Re: Grid sıralama ..

bahattin yazdı:

Soykan bey sizi   çok fazla meşgul etmek istemem ama..
ortada kolon ve header yok daha grid init de oluşturuyorum kolonları başlıkları
Şöyle..

grid init..

Visual Fox Pro
CREATE cursor cmv ;

(ctrh d(8),cgun n(3),cvad d(8),cksl c(5),cack c(41),cbrc n(15,2), calc n(15,2),cnum n(10))
 
local xctrh,xcgun,xcack,xcbrci,xcalc,xcksl,xcnum
*store 0 to xcbrci,xcalc
select crmvn
go top
select cmv
WITH thisform.grid1
*.WIDTH=500
.columncount=8
.deletemark=.f.
.scrollbars=2
.recordmark=.f.
.recordSource = ;
"cmv"
endwith
 
**kolon1 tarih
with thisform.grid1.column1
.width=70
thisform.grid1.column1.header1.caption='Tarih'
thisform.grid1.column1.header1.alignment=2
endwith
 
*!*    **kolon2 gün
with thisform.grid1.column2
.width=40
.format   ='###'
thisform.grid1.column2.header1.caption='Gün'
thisform.grid1.column2.header1.alignment=2
endwith
 
**kolon3 vade
with thisform.grid1.column3
.width=70
thisform.grid1.column3.header1.caption='Vade '
thisform.grid1.column3.header1.alignment=2
endwith
 
 
**kolon4 vade
with thisform.grid1.column4
.width=42
thisform.grid1.column4.header1.caption='Koşul '
thisform.grid1.column4.header1.alignment=2
endwith
 
**kolon5 vade
with thisform.grid1.column5
.width=295
thisform.grid1.column5.header1.caption='Açıklama'
thisform.grid1.column5.header1.alignment=2
endwith
 
**colon6  borç
with thisform.grid1.column6
.width=72
.inputmask='####,###.##'
.format   ='####,###.##'
endwith
thisform.grid1.column6.header1.caption=' Borç '
thisform.grid1.column6.header1.alignment=2
 
**colon7  alacak
with thisform.grid1.column7
.width=72
.inputmask='####,###.##'
.format   ='####,###.##'
endwith
thisform.grid1.column7.header1.caption=' Alacak '
thisform.grid1.column7.header1.alignment=2
 
 
**colon8  Belge no
with thisform.grid1.column8
.width=80
.inputmask='##########'
.format   ='##########'
endwith
 
thisform.grid1.column8.header1.caption=' Belge No '
thisform.grid1.column8.header1.alignment=2
go top
 
*This.SetAll("DynamicBackColor", "IIF(cmv.iz=1, RGB(0,0,160) , RGB(0,0,0))", "Column")
thisform.refresh()

bu kodla grid init de kolonlar oluştu.
şimdi

"thisform.grid1.column1.header1.click"  event inede ilk başta yazdığım kodu yada sizin verdiğiniz
sıralama kodunu yazacağım.
ama bunu nereye nasıl yazacağım.

grid de sütun yada başlık yok

teşekkür ederim


neden bunlari illa kodla ve initta olusturmaya calisiyorsun,kolonlari sabit se yani sorgu sonucu cursorden gelen degisken sayida kolonlar olmadigina gore design time da butun bu ayarlamalari yapabilirsin gerci senin kodlarinda initte cursor olusturuyorsun , sadece initte cursor yaratma kodu kullansanda gridin kolon sayisini cursor deki alan sayisi kadar kurup controlsource larina mesela cmv.cgun gibi yazarak ve gerekli yerlere onceki postta yazdigim kodlarini kullanarak bunu yapabilirsin

yada Tarkan ın dedigi gibi class olarak kullanacaksin

11

Re: Grid sıralama ..

Soykan bey merhaba..
Geç gördüm ama iyiki gördüm..

Ama dediğiniz gibi kolon sayıları falan değişmiyor.
hiç aklıma gelmedi.
Dizayn edilmemiş grid i n kolon sayısını 8 yaptım.
Header eventlerine yazma olanağı çıktı.
oradan hallederim herhalde..
Çok Teşekkür ederim..

İyi Çalışmalar dilerim