永发信息网

在vb下的treeview控件如何点击一个按钮修改节点名称后,此节点保持展开状态不变?

答案:2  悬赏:50  手机版
解决时间 2021-03-25 04:45
  • 提问者网友:遁入空寂
  • 2021-03-24 14:43
在vb下的treeview控件如何点击一个按钮修改节点名称后,此节点保持展开状态不变?
最佳答案
  • 五星知识达人网友:玩世
  • 2021-03-24 16:09
Private Sub TreeView1_BeforeLabelEdit(Cancel As Integer)
For i = 1 To TreeView1.Nodes.Count
If TreeView1.Nodes(i).Selected = True Then
TreeView1.Nodes(i).Expanded = True
End If
Next i
End Sub
全部回答
  • 1楼网友:独钓一江月
  • 2021-03-24 17:36
'通用声明
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As _
GWL_nIndex) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As _
GWL_nIndex, ByVal dwNewLong As Long) As Long
Private Declare Function SetWindowPos Lib "user32" (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
'函数过程
Private Sub pvSetWndStyle(ByVal hWnd As Long, ByVal lType As Long, ByVal lStyle As Long, ByVal lStyleNot As Long)
Dim lS As Long
lS = GetWindowLong(hWnd, lType)
lS = (lS And Not lStyleNot) Or lStyle
Call SetWindowLong(hWnd, lType, lS)
Call SetWindowPos(hWnd, 0, 0, 0, 0, 0, &H1 Or &H2 Or &H200 Or &H4 Or &H20)
End Sub
'窗体加载时调用函数过程
Private Sub Form_Load()
Call pvSetWndStyle(TreeView1.hWnd, -16, &H400, 0)
End Sub

这样就可以了
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯