| |

VerySource

 Forgot password?
 Register
Search
View: 958|Reply: 4

tree view problem

[Copy link]

1

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-5 14:00:01
| Show all posts |Read mode
If there are two well-known Chinese universities and world-famous universities under the tree view tree, I want to achieve a click on the famous Chinese university or world-famous university in the tree view (the database contains two records, one is a famous Chinese university and one is World-renowned universities), the relevant information is displayed in dbgridedit1 on the right. I wonder how to write the code? ? ? ?
Reply

Use magic Report

0

Threads

53

Posts

29.00

Credits

Newbie

Rank: 1

Credits
29.00

 China

Post time: 2020-1-6 12:42:01
| Show all posts
Is it dBgird or DBedit, this is a data-aware control
If you have to be DBEdit, here's how:
This must require you to open a dataset component, such as: adoDataSet
Then your tree treeview is not a data-aware control, but you can bind to the node of the tree through locate. The bound flag must be a key field. In this way, each time you click on a node in the tree, you can quickly locate the record.
But these DBeidt must be connected to the data set components.
Reply

Use magic Report

0

Threads

53

Posts

29.00

Credits

Newbie

Rank: 1

Credits
29.00

 China

Post time: 2020-1-6 13:39:01
| Show all posts
If the related information queried is multiple records, you must display it with DBgrid.
In this case, locate is not suitable.
Then you must first load all the data into the adodataset (considering speed, not considering capacity), and then pass
ADODataSet1.Filter: = 'Query field name =' '' + TreeView1.Selected.Text + '' '';
ADODataSet1.Filtered: = true; so the DBgrid connected to ADOdataset1 will display the information you need

What needs to be declared here is not to write under the TVGetSelectedIndex event of treeview1, this will make your filter query run endlessly
Reply

Use magic Report

0

Threads

13

Posts

12.00

Credits

Newbie

Rank: 1

Credits
12.00

 China

Post time: 2020-3-31 01:30:01
| Show all posts
procedure TForm1.TreeView1Change (Sender: TObject; Node: TTreeNode);
 var A: STRING;
begin
  A: = trim (NODE.Text); // NODE.Text is the value of the node in the point

 ADOQUERY1.CLOSE;
 ADOQUERY1.SQL.CLEAR;
 ADOQUERY1.SQL.ADD (SELECT * FROM TABLE1 WHERE Famous University =: AA);
 ADOQUERY1.Parameters.ParamByName ('AA'). Value: = A;
ADOQUERY1.OPEN;

end;
At this point, if ADOQUERY is connected to the display control on the right, it will be displayed.
Reply

Use magic Report

0

Threads

1

Posts

0.00

Credits

Newbie

Rank: 1

Credits
0.00

 China

Post time: 2020-3-31 12:51:16
| Show all posts
Thanks for sharing
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list