|
|
导航: |
论坛 -> DELPHI技术
斑竹:liumazi,sephil |
|
作者: |
cjjll (潇潇) |
★☆☆☆☆ |
-
|
盒子活跃会员 |
|
2004/3/24 15:15:10 |
标题: |
请教关于树显示问题(fcTreeView)--jjjj |
浏览:1551 |
|
加入我的收藏 |
楼主: |
各位,偶在查询生成树过程中遇到如下情况--第一次查询时能够生成并显示树,但是当进行第二次查询时却无法显示树了(经过跟踪发现树实际上已经生成只是显示有点问题--需要单击一下控件TfcTreeView才能显示出来)
附源码如下---请指正哈。 unit treeview;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, fcTreeView, DB, DBTables, StdCtrls, ComCtrls;
type TForm1 = class(TForm) TV1: TfcTreeView; DB: TDatabase; QryDG016: TQuery; TDG005: TQuery; Button1: TButton; CheckBox1: TCheckBox; DateTimePicker1: TDateTimePicker; DateTimePicker2: TDateTimePicker; CheckBox2: TCheckBox; ComboBox1: TComboBox; Button2: TButton; procedure Button1Click(Sender: TObject); procedure TV1CalcNodeAttributes(TreeView: TfcCustomTreeView; Node: TfcTreeNode; State: TfcItemStates); procedure ComboBox1Change(Sender: TObject);
private { Private declarations } fgs, fgs1, fgs2: TfcTreeNode; procedure UpTV; public { Public declarations } end;
var Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject); begin QryDG016.close; QryDG016.SQL.Clear; QryDG016.SQL.Add('select HT016002,HT016001,HT016020 from DG016'); QryDG016.sql.Add('where HT016020=10106'); //QryDG016.SQL.SaveToFile('c:\1.txt'); QryDG016.open; UpTV; end;
procedure TForm1.UpTV; begin //TV1.Canvas.Refresh; //TV1.Canvas.Create; fgs := nil; fgs1 := nil; fgs2 := nil; TV1.Items.Clear;
QryDG016.First; while not QryDG016.Eof do begin fgs1 := TV1.Items.AddChild(nil, QryDG016.fieldbyname('ht016002').asstring); fgs1.ImageIndex := 0; fgs1.SelectedIndex := 1; fgs1.StateIndex := 0; fgs1.StringData := 'A1'; fgs1.StringData2 := QryDG016.fieldbyname('ht016001').asstring; fgs1.CheckboxType := tvctNone; // TDG005.Close; TDG005.sql.Clear; TDG005.SQL.Add('select dg005001 from dg005 '); TDG005.SQL.Add('where dg005003=''' + QryDG016.fieldbyname('ht016001').asstring + ''''); if CheckBox1.Checked then TDG005.SQL.Add('and to_char(dg005005,''YYYY-MM-DD'') between ''' + FormatDateTime('YYYY-MM-DD', DateTimePicker1.DateTime) + ''' and ''' + FormatDateTime('YYYY-MM-DD', DateTimePicker2.DateTime) + ''''); if CheckBox2.Checked then begin if ComboBox1.ItemIndex = 0 then TDG005.SQL.Add(' and (dg005006=''收料'') '); if ComboBox1.ItemIndex = 1 then TDG005.SQL.Add(' and (dg005006=''初值'') '); end; TDG005.open; TDG005.First; // while not TDG005.Eof do begin fgs2 := TV1.Items.AddChild(fgs1, TDG005.fieldbyname('dg005001').asstring); fgs2.ImageIndex := 0; fgs2.SelectedIndex := 1; fgs2.StateIndex := 0; fgs2.StringData := 'A2'; fgs2.StringData2 := TDG005.fieldbyname('dg005001').asstring; fgs2.CheckboxType := tvctNone; TDG005.Next; end; // QryDG016.Next; end; // end;
procedure TForm1.TV1CalcNodeAttributes(TreeView: TfcCustomTreeView; Node: TfcTreeNode; State: TfcItemStates); begin // end;
procedure TForm1.ComboBox1Change(Sender: TObject); begin UpTV; end;
end.
----------------------------------------------
- |
|