在vb.net 2010中的TreeViewList中使用选择大小写 [英] Using select case in TreeViewList in vb.net 2010

查看:81
本文介绍了在vb.net 2010中的TreeViewList中使用选择大小写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有个问题.代码的用途是:假设我有2个根,每个根都有2个孩子.然后,我想通过双击选项进行编码.这是我的代码示例:

Hi all,

I have a problem. What is the code for: Let say that I have 2 root and each root have 2 child. Then I want to code by double-click option. This is example of my code:

Private Sub tvlist_DoubleClick
    Select Case tvList.SelectedNode.Name
       Case 0
                If tvList.SelectedNode.Text = "Add Data" Then
                    tvList.SelectedNode.Checked = True
                    Dim memberReg As New System.Windows.Forms.Form
                    memberReg = frmMemberReg
                    memberReg.MdiParent = Me
                    memberReg.Show()
                End If
       Case 1
                If tvList.SelectedNode.Text = "Edit Data" Then
                    tvList.SelectedNode.Checked = True
                    Dim memberReg As New System.Windows.Forms.Form
                    memberReg = frmMemberReg
                    memberReg.MdiParent = Me
                    memberReg.Show()
                End If
    End Select
End Sub



---->这段代码我错了吗?因为我尝试了"Select Case tvList.SelectedNode.Index",但是我看到了该节点,所以其中一些索引为0.其他索引.有人可以帮我解决这个问题吗?以及如何显示将显示的表单自动最大化?



----> Am I wrong with this code? Because I have try the "Select Case tvList.SelectedNode.Index" but I''ve see the node, some of them have the index 0. I''m afraid that if I call the index 0 from nodes, it will conflict from other index. Could someone help me solve this matter? And how could I code the form by maximize it automatically when it will display?

推荐答案

我不确定在这里要做什么.
我猜您希望能够确定用户单击了哪个节点.
一种方法是像在代码中一样检查选中节点的名称.
但是,如果此名称不是唯一的,则会出现问题.

另一种方法是向每个节点的标签添加唯一标识符.
我假设您在代码中填充了树视图列表,因此可以在每个节点的tag属性中添加一个唯一键.
然后,您可以简单地检查selectednode的tag属性,并使用该属性来确定要执行的操作.

关于第二个问题,即如何在显示时最大化表格:

有一个窗体属性windowstate.将其设置为最大化. (无论是在设计器中还是在代码中)
I''m not sure what you want to do here.
I''m guessing you want to be able to identify what node the user clicked on.
One way to do this is by checking the name from the selectednode as you did in your code.
However if this name isn''t unique you will have problems.

Another way is to add a unique identifier to the tag of each node.
I''m assuming you fill the treeviewlist in code, so you can add a unique key into the tag property of each node.
Then you can simply check the tag property of the selectednode and use that to determine what action to take.

As to your second question of how to maximize the form when it displays:

There is a form property windowstate. Set it to maximized. (either in designer or in code)


这篇关于在vb.net 2010中的TreeViewList中使用选择大小写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆