| View previous topic :: View next topic |
| Author |
Message |
sekar1 Member
Joined: 21 Dec 2006 Posts: 13
|
Posted: 06/02/07 11:51 Post subject: TREE VIEW - display |
|
|
| i am using the tree view for reading and displaying the data read from the file.. the file contains group and sub groups (Many).. i read the data and stored the name and data in the seperate arrays.the problem is how should i show the subgroups and goups name in the tre view?
|
|
| Back to top |
|
 |
Kambiz Administrator

Joined: 07 Mar 2003 Posts: 1231 Location: Tehran, Iran
|
Posted: 06/02/07 18:13 Post subject: |
|
|
Have you ever tried to click on a TreeView control on a form and then press F1?
_________________ Kambiz
 |
|
| Back to top |
|
 |
sekar1 Member
Joined: 21 Dec 2006 Posts: 13
|
Posted: 08/02/07 08:33 Post subject: |
|
|
| Ya.. i tried but the thing is that my problem is of something like this.. in a file there is no of groups and in each groups there are no of sub groups Example:(customer database(Name) -> Yearly(nearly five year) -> monthly( 12 monthsfor each year) .. i need to develop a code which will allocate the names, year and in each year every month in the treenode automatically... i am wrestling for this nearly more than a week... can anyone send the solution r suggest some valuable ideas which will be positive to the solution?
|
|
| Back to top |
|
 |
Kambiz Administrator

Joined: 07 Mar 2003 Posts: 1231 Location: Tehran, Iran
|
Posted: 08/02/07 14:19 Post subject: |
|
|
You can use the following set of functions as a template.
| Code: | function FindNode(Tree: TTreeView; const Name: String; Year, Month: Word): TTreeNode;
function FindChild(Parent: TTreeNode; const Target: String): TTreeNode;
var
I: Integer;
begin
Result := Parent;
for I := 0 to Parent.Count - 1 do
if SameText(Parent.Item[I].Text, Target) then
begin
Result := Parent.Item[I];
Exit;
end;
end;
var
I: Integer;
begin
Result := nil;
for I := 0 to Tree.Items.Count - 1 do
if SameText(Tree.Items[I].Text, Name) then
begin
Result := FindChild(Tree.Items[I], IntToStr(Year)); // Look for year
if Result.Level = 1 then // Year is found
Result := FindChild(Result, IntToStr(Month)); // Look for month
Exit;
end;
end;
function AddToTree(Tree: TTreeView; const Name: String; Year, Month: Word): TTreeNode;
begin
Result := FindNode(Tree, Name, Year, Month);
if not Assigned(Result) then
Result := Tree.Items.AddChild(nil, Name);
if Result.Level = 0 then
Result := Tree.Items.AddChild(Result, IntToStr(Year));
if Result.Level = 1 then
Result := Tree.Items.AddChild(Result, IntToStr(Month));
end;
procedure BuildTree(Tree: TTreeView; Table: TTable);
var
Name: String;
Year, Month, Day: Word;
begin
Tree.Items.BeginUpdate;
try
Tree.Items.Clear;
Table.First;
while not Table.Eof do
begin
// Retrieve name and date
Name := Table.FieldValues['Name'];
DecodeDate(Table.FieldValues['Date'], Year, Month, Day);
with AddToTree(Tree, Name, Year, Month) do
begin
// customize the new node
Text := Table.FieldValues['Description'];
end;
Table.Next;
end;
Tree.AlphaSort;
finally
Tree.Items.EndUpdate;
end;
end; |
_________________ Kambiz
 |
|
| Back to top |
|
 |
sekar1 Member
Joined: 21 Dec 2006 Posts: 13
|
Posted: 13/02/07 05:22 Post subject: |
|
|
| thanx for your help
|
|
| Back to top |
|
 |
sekar1 Member
Joined: 21 Dec 2006 Posts: 13
|
Posted: 26/02/07 05:35 Post subject: Reg writing a ascii file |
|
|
hi kambiz,
thanks for your great support in writing the code for my application.. now, iam developing the code to create a file in ascii format from a already stored recored.. the file should be look like a table.. name, decription, quantity like this, there much be around 1000 to some ten thousand elements set in the record.. the problem i am facing is to set the space constraints between the two variable while writing..
for ex i am writing the one line of the ouptu file in normal format..
| Code: |
Si.No---Name------Xvalue----------Yvalue-----------Yunit------Time
1.-------Grid--------0.001254896---180.1245698----Watts-----20/2/2007
|
like this the line(--- space tabs) should be of aligned as a uniform column. the problem is some data is having 4 decimal values and some other is having 12 decimal values.. i am facing problem in using character strings(#13) that i tried.
please give some suggestions to solve this.. i tried in help also but finding any good solutions..
//EDIT by J_B: use the code Luke! And whatever browser you use, make sure it has Dictionary... I won't fix it for you.
|
|
| Back to top |
|
 |
Kambiz Administrator

Joined: 07 Mar 2003 Posts: 1231 Location: Tehran, Iran
|
Posted: 26/02/07 09:46 Post subject: |
|
|
Look for Write procedure in Delphi help.
_________________ Kambiz
 |
|
| Back to top |
|
 |
sekar1 Member
Joined: 21 Dec 2006 Posts: 13
|
Posted: 10/04/07 14:10 Post subject: Reg: treeview |
|
|
hi kambiz,
reg the treeview that i asked early, i av some doubts.
i created the treeview component in main class. i stored the data as seperate classes in another file(.pas file).. can i call the main class inside this one and declared the treeview function. if i want to do means i need to declare the main class as an object in another file.. i tried in normal way.. but it shows some error...
the main thing is that i declared the database name and other variable as private in seperate class and i created property to access the variable..
can u suggest some way..
|
|
| Back to top |
|
 |
Johnny_Bit Administrator
Joined: 15 Jun 2003 Posts: 397
|
Posted: 10/04/07 15:12 Post subject: |
|
|
by all means, may I?
Firs of all, the fault is yours, you simply use OOP improperly.
Second, "but it shows some error..." well, I've got some fix.
Third, I've read through your post several times and still I don't get it.
Last but not least, firefox with spellcheck, plz.
I suggest you to clarify what you want to do when you want to get decent answer.
|
|
| Back to top |
|
 |
|