有If語句搭配即可:If

站在用戶的角度思考問題,與客戶深入溝通,找到啟東網(wǎng)站設(shè)計與啟東網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗(yàn),讓設(shè)計與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個性化、用戶體驗(yàn)好的作品,建站類型包括:成都網(wǎng)站設(shè)計、網(wǎng)站建設(shè)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣、域名注冊、網(wǎng)站空間、企業(yè)郵箱。業(yè)務(wù)覆蓋啟東地區(qū)。
object.value
=
True
Then '但單選框被選中時
......
'所執(zhí)行的語句Else '當(dāng)單選框沒有被選中時 ......
'所執(zhí)行的語句End
If其中,object是需要被判斷的單選框名稱
添加:(先在加一個contextMenu,再它的添加子菜單的click事件編程)
Try
’使TreeView可以被編輯
TreeView1.LabelEdit = True
‘判斷你是不是選定的是不可編輯的節(jié)點(diǎn),我這里工種節(jié)點(diǎn)不可以被編輯,只有工種下級的
各個工種名稱可以被編輯
If Trim(TreeView1.SelectedNode.Text) = "工種" Then
‘添加節(jié)點(diǎn)
AddNode = New TreeNode("請輸入新工種名字")
TreeView1.SelectedNode.Nodes.Add(AddNode)
TreeView1.ExpandAll()
AddNode.BeginEdit()
TreeView1.LabelEdit = True
NodeAdded = True
End If
Catch err As Exception
MsgBox(err.ToString)
End Try
刪除與添加類似,只是如果你的節(jié)點(diǎn)名字從其他處(如數(shù)據(jù)庫)得來,那么你還需要更新數(shù)據(jù)庫
編輯:
Private Sub TreeView1_BeforeLabelEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.NodeLabelEditEventArgs) Handles TreeView1.BeforeLabelEdit
TreeView1.LabelEdit = True ‘使可以編輯
AddNode = TreeView1.SelectedNode
End Sub
Private Sub TreeView1_AfterLabelEdit(ByVal sender As Object, ByVal e As System.windows.Forms.NodeLabelEditEventArgs) Handles TreeView1.AfterLabelEdit
Try
‘此時你改完了節(jié)點(diǎn)名字
TreeView1.SelectedNode.EndEdit(True)
If e.Label Is Nothing Then
'do nothing
ElseIf e.Node.Text = "工種" Then ‘工種不能改
e.CancelEdit() = True
‘e.Node.Text ,e.Label.ToString 一個是改前的名字一個是該后的名字,具體哪個對
哪個請查MSDN
ElseIf Trim(e.Node.Text) "工種" And e.Node.Text e.Label.ToString Then
If MsgBox("此操作會導(dǎo)致當(dāng)前工種中的所有人員的工種都被更改,是否確定?", MsgBoxStyle.YesNo + MsgBoxStyle.Information, "警告") = MsgBoxResult.Yes Then
。。。。 ‘我的更改
MsgBox("更改成功!", MsgBoxStyle.OKOnly, "提示")
'Call InitTree() ‘有時要重新把treeview初始化一遍,視需求定
End If
End If
Catch err As Exception
MsgBox(err.ToString)
End Try
End Sub
其他:
擋treeview得到焦點(diǎn)時你可以使用ContextMenu,反之ContextMenu禁用
Private Sub TreeView1_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles TreeView1.GotFocus
TreeView1.ContextMenu = ContextMenu1
End Sub
Private Sub TreeView1_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles TreeView1.LostFocus
TreeView1.ContextMenu = Nothing
End Sub
注意:這里沒有在ContextMenu菜單添加“更改”項(xiàng),而是直接更改:即左鍵單擊節(jié)點(diǎn)表示
選中,再單擊一下就可以編輯了,更改之后單擊他處就完成更改,和你在windows中更改文
件名字相似。
這個簡單。
在VB.net中,每個事件都對應(yīng)有兩個參數(shù):sender 和 e 。提取 sender 參數(shù)信息就可以獲取控件名稱。如果不理解其中機(jī)制,你直接 msgbox(sender) 將其輸出,就能查看其中玄機(jī)。
獲取控件名稱代碼:CType(sender, Control).Name。
網(wǎng)站題目:vb.net單選框名稱,vb單選框和復(fù)選框
鏈接分享:http://chinadenli.net/article25/dsgisji.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供用戶體驗(yàn)、自適應(yīng)網(wǎng)站、動態(tài)網(wǎng)站、全網(wǎng)營銷推廣、網(wǎng)站制作、建站公司
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)