treeview控件问题,各位大侠帮忙200分(0)

  • 主题发起人 主题发起人 wisdomphg
  • 开始时间 开始时间
W

wisdomphg

Unregistered / Unconfirmed
GUEST, unregistred user!
procedure Tb_bmygform.Button1Click(Sender: TObject);var strbh,strName:string; myNode:TTreeNode; QryTmp:TADOQuery;begin Application.CreateForm(TF_ADD, F_ADD); F_ADD.Caption :='增加'; if F_ADD.showmodal=mrok then begin strbh:=trim(F_ADD.Edit3.Text+F_ADD.Edit1.Text); if strbh='' then exit; QryTmp:=TADOQuery.Create(self); QryTmp.ConnectionString:=linkstr; QryTmp.SQL.Add('select * from gbmyg where item_no='''+strbh+''''); QryTmp.Open; if QryTmp.RecordCount=0 then begin strName:=trim(F_ADD.Edit2.Text); if strName='' then exit; if F_ADD.RzRadioButton1.Checked then begin myNode:=TreeView1.Items.Add(TreeView1.Selected,strbh+' '+strname); sbh[mynode.Index,0]:=strbh; sbh[mynode.Index,1]:=strname; if assigned(TreeView1.Selected) then AddDataToDB_list(myNode,TreeView1.Selected.Parent) else AddDataToDB_list(myNode,nil); myNode.selected:=true; end else begin myNode:=TreeView1.Items.AddChild(TreeView1.Selected,strbh+' '+strname); sbh[mynode.Index,0]:=strbh; sbh[mynode.Index,1]:=strname; AddDataToDB_list(myNode,TreeView1.Selected); myNode.selected:=true; end; end; QryTmp.Close; QryTmp.Free; end; F_ADD.free;end;增加主节点没问题,增加一个子节点报错报错如下:违报了primarykey约束'pk_gbmyg',不能在对象gbmyg中插入重复键.
 
后退
顶部