为什么不接受基于textbox.text的treeview selectednode? [英] Why not accept treeview selectednode based ontextbox.text ?

查看:80
本文介绍了为什么不接受基于textbox.text的treeview selectednode?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试基于TextBox.Text设置焦点TreeViewNode(不小心大写,小写)时没有结果。



对于Excample节点标记是C :\ 7143 \ Baltek)



如果我输入C:\ 7143 \ baltek)或C:\ 7143 \ BalteK )没有结果,因为Upper LowerCase打字



如何调整以找不到任何类型的textbox.text。



我尝试过:



When I try to set focus TreeViewNode based on TextBox.Text (with dont care uppercase, lowercase) then no result.

For Excample Node Tag is "C:\7143\Baltek")

if I enter "C:\7143\baltek") or "C:\7143\BalteK") no result, because of Upper LowerCase typing

how can I adjust to find not with any type textbox.text.

What I have tried:

Private Sub Button12_Click(sender As Object, e As EventArgs) Handles Button12.Click
        
        'Expand(TextBox3.Text) '("C:\7143\Baltek")
        gotNode = False
        For Each n As TreeNode In Me.TreeView1.Nodes
            If Not gotNode Then
                
                selectTreeNode(n, TextBox3.Text) ' "C:\7143\Baltek")

                
            End If
          
        Next

    End Sub

推荐答案

我建​​议从这开始:比较圣.NET中的环Microsoft Docs [ ^ ]



如果你想忽略大小写,请检查:String.Equals Method(System)| Microsoft Docs [ ^ ]



I'd suggest to start with this: Comparing Strings in .NET | Microsoft Docs[^]

If you want to ignore case, check this: String.Equals Method (System) | Microsoft Docs[^]

Dim node2find = Me.TreeView1.Nodes.Cast(Of TreeNode)() _
	.Where(Function(n) n.Text.Equals(TextBox3.Text, StringComparison.InvariantCultureIgnoreCase)) _
	.ToList()





上面的代码将返回一个节点列表,其中的文本等于 TextBox3.Text 忽略案例。





如果你想比较一部分文字,你需要使用以下字符串函数:

StartsWith

包含

EndsWith

请按照第一个链接(在第我的答案的顶部)。



Above code will return a list of nodes which text equals to TextBox3.Text ignoring case.


In case you want to compare a part of text, you need to use of of the following string functions:
StartsWith
Contains
EndsWith
Please, follow the first link (on the top of my answer).


这篇关于为什么不接受基于textbox.text的treeview selectednode?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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