给你参考个代码
treeviewitem tv_cur,tv_new
long ll_root,new_handle
string ls_closetype
//
ist_parm.opentype = "add"
ls_closetype = gs_closetype
ist_parm.int2 = ai_parentid
gs_closetype = '0'
openwithparm(w_knowledge_add,ist_parm,this)
if gs_closetype='1' then
//如果是点击确定按钮 或者 取消按钮
ist_parm = message.powerobjectparm
if ist_parm.closetype='ok' then
ll_root = tv_1.getitem(al_handle,tv_cur)
if ll_root<>-1 then
if tv_cur.ExpandedOnce=true and tv_cur.Children=true then
//如果当前节点已经存在子节点
tv_new.SelectedPictureIndex = 3
tv_new.PictureIndex = 2
tv_new.label = ist_parm.string4
if ist_parm.int4<5 then tv_new.label = tv_new.label +"【" +levelcode[ist_parm.int4]+"】"
tv_new.data = string(ist_parm.int3)
new_handle=tv_1.InsertItemlast(al_handle,tv_new)
else
//如果没有子节点
tv_cur.Children=true
tv_1.SetItem(al_handle,tv_cur)
end if
end if
end if
//
//
// //ClassicGSMType
// //messagebox("","1")
end if
gs_closetype = ls_closetype
if tv_1.getitem(ii_handle,tv_item) = -1 then return
tv_item.label = ls_mess
select max(to_number(treeid)) into :ls_treeid from bm_bqbmb0_tree ;
ll_treeid=long(ls_treeid)+1
ls_parentid=string(tv_item.data)
ls_treeid=string(ll_treeid)
insert into bm_bqbmb0_tree(treeid,treename,parentid)
values(:ls_treeid,:ls_mess,:ls_parentid);
if sqlca.sqlcode<>0 then
messagebox("提示","生成数据失败!"+sqlca.sqlerrtext)
return
else
commit;
ltvi_new.label = ls_mess
ltvi_new.data = ls_treeid
ltvi_new.children = false
// tv_1.insertitemlast(ii_handle,ltvi_new)
tv_1.expanditem(ii_handle)
messagebox("提示","新增病情编码成功!")
end if