既然你不愿意去下载我以前放的源代码,只有我自己找给你了。
看看是否用的著。
=========================================================
procedure TForm1.ToolButton17Click(Sender: TObject);
var
Node,CatNode,ParentNode:TTreeNode;
I:Integer;
begin
if ActiveControl=RichEdit1 then
RichEdit1.ClearSelection
else if ActiveControl=TreeView1 then
begin
Node:=TreeView1.Selected;
ParentNode:=Node.Parent;
if Node.Level=2 then
Table1.Delete
else
begin
if Node.HasChildren then
begin
if MessageDlg('ɾ³ýÕâ¸öÖ÷ÌâÏÂËùµÄ×ÊÁÏÂð?',mtConfirmation,[mbYes, mbNo],0)=idNo then
Exit;
Table1.DisableControls;
try
for I:=0 to Node.Count-1 do
begin
if Table1.Locate('Subject', Node.Item.Text,[]) then
Table1.Delete;
end;
finally
Table1.EnableControls;
end;
end;
Table2.Locate('Level',Node.Text,[]);
Table2.Delete;
end;
TreeView1.Items.Delete(Node);
ParentNode.Selected:=True;
end
else if ActiveControl = ListView2 then
begin
I := 0;
while I < ListView2.Items.Count do
begin
if Listview2.Items.Selected then
begin
if Table1.Locate('Subject',ListView2.Items.Caption,[]) then
Table1.Delete;
Treeview1.Items.Delete(Treeview1.Selected.Item);
Listview1.Items.Delete;
end
else
Inc(I);
end;
end
else if ActiveControl = ListView1 then
begin
CatNode := TreeView1.Selected.Item[Listview1.Selected.Index];
if CatNode.HasChildren then
begin
if MessageDlg( '&Eacute;&frac34;&sup3;&yacute;&Otilde;&acirc;&cedil;&ouml;&Ouml;÷&Igrave;&acirc;&Agrave;&iuml;&micro;&Auml;&Egrave;&laquo;&sup2;&iquest;×&Ecirc;&Aacute;&Iuml;&Acirc;&eth;?',mtConfirmation,[mbYes,mbNo],0)=idNo then
Exit;
Table1.DisableControls;
try { Move table cursor to selected subject }
for I:=0 to CatNode.Count-1 do
begin
if Table1.Locate('Subject', CatNode.Item.Text,[]) then
Table1.Delete;
end;
finally
Table1.EnableControls;
end;
end;
Table2.Locate('Level',CatNode.Text,[]);
Table2.Delete;
ListView1.Selected.Delete;
TreeView1.Items.Delete(CatNode);
end;
end;