1

Konu: Treeview ve listview hakkında

selam arkadaşlar

Treeview elemanlarını listview e eklemek istiyorum tam olarak komut kalıplarını bilmiyorum
seçilen treeview elemanlarını listview e nasıl ekleyebilirm? veya root u nasıl ekleyebilirim. herhangi bir örnek olabilir

veya
listview 'e komutlarını yazarsanız sevinirim

2

Re: Treeview ve listview hakkında

Umarim bu isine yarar.
Uyari: Kodun kotusu olmaz:) diye mevcut bir test kodunu gonderiyorum. Koda bakan deneyimli kullanicilar bir suru elestiriyle atlayacak, sana yardim etmek icin tamam, yoksa ben farkindayim kodun optimize olmadiginin:)

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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
#Define tvwFirst    0

#Define tvwLast 1
#Define tvwNext 2
#Define tvwPrevious 3
#Define tvwChild    4
 
Public oForm
oForm = Createobject('lvForm')
oForm.Show()
 
Define Class lvForm As Form
  DataSession = 2
  Height = 400
  Width = 800
  Add Object tv As OleControl With ;
    Left =   0,Height = 400,Width = 200, OleClass = 'MSComCtlLib.TreeCtrl'
  Add Object lv As OleControl With ;
    Left = 200,Height = 400,Width = 600, OleClass = 'MSComCtlLib.ListviewCtrl.2'
 
  Procedure Init
    Thisform.tvSetUp()
    Thisform.lvSetUp('All')
  Endproc
 
  Procedure tv.NodeClick
    Lparameters Node
    Node.ensurevisible
    Thisform.lvSetUp(Node.Key)
  Endproc
 
 
  Procedure lv.ItemClick
    Lparameters Item
    Thisform.lvSetUp(Item.Key)
  Endproc
 
  Procedure lvSetUp(tcKey)
    If !(m.tcKey  == 'All' Or ;
        m.tcKey  = 'Cntry_' Or ;
        m.tcKey = 'Cust_' Or ;
        m.tcKey = 'Ord_')
      Return
    Endif
 
    With Thisform.tv
      .SelectedItem = .Nodes( m.tcKey )
      .SelectedItem.ensurevisible
    Endwith
 
    With Thisform.lv
      .ListItems.Clear()
      .ColumnHeaders.Clear()
      Do Case
        Case m.tcKey = 'All'
          .View = 2
          .ColumnHeaders.Add( , , "Country", 200)
          .ColumnHeaders.Add( , , "Customer Count", 50)
          Select country, Cnt(*) As CustomerCount ;
            From (_samples+"data\customer") ;
            Where !Empty(country) ;
            GROUP By country ;
            Into Cursor grpByCountry
          Scan
            itmX = .ListItems.Add(Recno(), 'Cntry_'+Trim(grpByCountry.country))
            itmX.Text = Trim(grpByCountry.country)
            itmX.SubItems(1) = Transform(grpByCountry.CustomerCount)
          Endscan
          Use In 'grpByCountry'
 
        Case m.tcKey = 'Cntry_'
          .View = 3
          .ColumnHeaders.Add( , , "Title",   150)
          .ColumnHeaders.Add( , , "Contact", 150)
          .ColumnHeaders.Add( , , "Company", 200)
          .ColumnHeaders.Add( , , "Country", 100)
 
          Select * From (_samples+"data\customer") ;
            Where country == Substr(m.tcKey,Len('Cntry_')+1) ;
            Into Cursor crsDetail
          Scan
            itmX = .ListItems.Add(,'Cust_'+crsDetail.cust_id)
            itmX.Text = crsDetail.Title
            itmX.SubItems(1) =crsDetail.contact
            itmX.SubItems(2) =crsDetail.Company
            itmX.SubItems(3) =crsDetail.country
          Endscan
          Use In 'crsDetail'
 
        Case m.tcKey = 'Cust_'
          .View = 3
          .ColumnHeaders.Add( , , "Order No",    50)
          .ColumnHeaders.Add( , , "Salesman",    200)
          .ColumnHeaders.Add( , , "Date Ordered",200)
          .ColumnHeaders.Add( , , "Ship Date",   200)
 
          Select * ;
            From (_samples+"data\orders") ord ;
            INNER Join (_samples+"data\employee") emp ;
            ON ord.emp_id == emp.emp_id ;
            Where cust_id == Substr(m.tcKey,Len('Cust_')+1) ;
            Into Cursor crsDetail
          Scan
            itmX = .ListItems.Add(,'Ord_'+Padl(Int(Val(crsDetail.order_id)),6,'0') )
            itmX.Text = Padl(Int(Val(crsDetail.order_id)),6,'0')
            itmX.SubItems(1) = Trim(crsDetail.First_Name - (' '+crsDetail.Last_Name))
            itmX.SubItems(2) = Transform(crsDetail.Order_date,'@YL')
            itmX.SubItems(3) = Transform(crsDetail.Shipped_on,'@YL')
          Endscan
          Use In 'crsDetail'
        Case m.tcKey = 'Ord_'
          .View = 3
          .ColumnHeaders.Add( , , "Line No",      50)
          .ColumnHeaders.Add( , , "Product Name", 250)
          .ColumnHeaders.Add( , , "Quantity",     50, 1)
          .ColumnHeaders.Add( , , "Price",        120,1)
          .ColumnHeaders.Add( , , "Ext.Price",    120,1)
 
          Select oi.*, prd.Prod_Name ;
            From (_samples+"data\orditems") oi ;
            INNER Join (_samples+"data\products") prd ;
            ON oi.product_id == prd.product_id ;
            Where Val(order_id) = Val(Substr(m.tcKey,Len('Ord_')+1)) ;
            ORDER By line_no ;
            Into Cursor crsDetail
          Scan
            itmX = .ListItems.Add(,;
              'Oi_'+Padl(Int(Val(crsDetail.order_id)),6,'0')+;
              Padl(crsDetail.line_no,6,'0') )
            itmX.Text = Transform(crsDetail.line_no)
            itmX.SubItems(1) = crsDetail.Prod_Name
            itmX.SubItems(2) = Transform(crsDetail.Quantity)
            itmX.SubItems(3) = Transform(crsDetail.Unit_Price,'@($')
            itmX.SubItems(4) = Transform(crsDetail.Unit_Price*crsDetail.Quantity,'@($')
          Endscan
          Use In 'crsDetail'
      Endcase
    Endwith
  Endproc
 
  Procedure tvSetUp(tcKey)
    Local oNode
    Local Array oNodes[1]
    With Thisform.tv
      Do Case
        Case Empty(m.tcKey)
          .linestyle = 1
          .Font.Name = 'Times New Roman'
          .Font.Size = 10
          .indentation = 5
          .LabelEdit = 1
          .HideSelection = .F.
 
          oNode = .Nodes.Add(,tvwFirst,'All','Ihracat Yaptigimiz Ulkeler:=)')
          Thisform.tvSetUp(oNode.Key)
        Case m.tcKey = 'All'
          Select country, Cnt(*) As CustomerCount ;
            From (_samples+"data\customer") ;
            Where !Empty(country) ;
            GROUP By country ;
            Into Cursor grpByCountry
          Dimension oNodes[_Tally]
          oNodes = .Null.
          Scan
            oNodes[RECNO()] = .Nodes.Add(m.tcKey,tvwChild,;
              'Cntry_'+Trim(grpByCountry.country),;
              Trim(grpByCountry.country))
          Endscan
          Use In 'grpByCountry'
          For Each oNode In oNodes
            Thisform.tvSetUp( oNode.Key )
          Endfor
        Case m.tcKey = 'Cntry_'
          Select * From (_samples+"data\customer") ;
            Where country == Substr(m.tcKey,Len('Cntry_')+1) ;
            Into Cursor crsDetail
          Dimension oNodes[_Tally]
          oNodes = .Null.
          Scan
            oNodes[RECNO()] = .Nodes.Add(m.tcKey,tvwChild, ;
              'Cust_'+crsDetail.cust_id, crsDetail.Company)
          Endscan
          Use In 'crsDetail'
          For Each oNode In oNodes
            Thisform.tvSetUp( oNode.Key )
          Endfor
        Case m.tcKey = 'Cust_'
          Select * ;
            From (_samples+"data\orders") ord ;
            INNER Join (_samples+"data\employee") emp ;
            ON ord.emp_id == emp.emp_id ;
            Where cust_id == Substr(m.tcKey,Len('Cust_')+1) ;
            Into Cursor crsDetail
          Scan
            .Nodes.Add(m.tcKey,tvwChild,;
              'Ord_'+Padl(Int(Val(crsDetail.order_id)),6,'0'),;
              'Order#:'+Padl(Int(Val(crsDetail.order_id)),6,'0'))
          Endscan
          Use In 'crsDetail'
      Endcase
    Endwith
  Endproc
Enddefine
Yen yaz 1907'ye yolla FB gelsin evinde yensin.
(sonra salaklar ciksin alin terine şike desin)

3

Re: Treeview ve listview hakkında

çetin hocadan kötü kod çıkmaz!

Bilmediğin Neyse Yanıldığındır.

4

Re: Treeview ve listview hakkında

tşk ederim çetin bey