gpt4 book ai didi

vb.net - 使 ListView FindItemWithText 匹配整个文本

转载 作者:行者123 更新时间:2023-12-02 02:46:50 25 4
gpt4 key购买 nike

我有一个包含两列的ListView,在 ListView 中输入新项目之前,我想防止输入重复的值,所以我找到了ListView.FindItemWithText来实现这一目标。

但我意识到,如果我输入 232323,然后输入 2323(这是不同的,但以与第一个条目相同的数字开头),该函数将返回该项目作为一场比赛。

我想知道是否有任何方法可以匹配整个文本(精确文本)以避免上述情况。

这是我的代码:

Dim ChkSIM As New ListViewItem
ChkSIM = lvItems.FindItemWithText("2323")
If Not ChkSIM Is Nothing Then
lblErrorSIM.Text = "Already in list"
End If

最佳答案

ListView.FindItemWithText 有一个重载,仅查找完全匹配:

Dim ChkSIM As ListViewItem = lvItems.FindItemWithText("2323", True, 0, False)

有关详细信息,请参阅the documentation .

关于vb.net - 使 ListView FindItemWithText 匹配整个文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11130231/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com