如果不匹配组合框文本和组合列出的项目不匹配,如何显示消息?该消息是“未找到项目”。 [英] How show a message when mismatch combo box text and combo listed item are not match? The message is "item not found"

查看:73
本文介绍了如果不匹配组合框文本和组合列出的项目不匹配,如何显示消息?该消息是“未找到项目”。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果不匹配组合框文本和组合列出的项目不匹配时如何显示消息?消息是找不到项目我在vb.net 2008中创建了一个带有ms访问数据库的项目。

项目列表在组合框中但如果我没有点击列表项,那么它就是留在组合框中,现在我在这个位置去其他领域然后显示消息框找不到项目。

Fox示例:

组合框项目是

A

B

C

D

E

F



但如果我输入g / h / i / j / .....它会在组合框中保留无异议

请帮帮我。



我的尝试:



如果ComboBox1.SelectedItem.text = ComboBox1.Text则
MsgBox(ok)
否则
MsgBox(not)
结束如果

解决方案

我记得今天早些时候回答这个完全相同的问题,答案仍然是一样的。



如果在行上设置断点:

 如果 ComboBox1.SelectedItem.text = ComboBox1.Text 那么 

并查看被比较的变量的值,您将得到答案。


我认为方法是错误的,您应该查看FindStringExact方法。想想它就像你想知道你输入的内容存在于组合框中而不是你输入的内容(comboBox1.Text)与你选择的相同(ComboBox1.SelectedItem.text)。



  if (comboBox1.FindStringExact(comboBox1.Text)> -1)然后 


How show a message when mismatch combo box text and combo listed item are not match? The message is "Item Not Found" I create a project in vb.net 2008 with ms access data base.
Item list are in combo box but if I not click on the list item just anything it is stay on the combo box, now in this position when I go to other field then show the message box "Item not found".
Fox Example :
combo box item is
A
B
C
D
E
F

But if I type g/h/i/j/..... it stay on the combo box no objection
please help me.

What I have tried:

If ComboBox1.SelectedItem.text = ComboBox1.Text Then
            MsgBox("ok")
        Else
            MsgBox("not")
        End If

解决方案

I remember answering this exact same question earlier today and the answer still remains the same.

If you set a breakpoint on the line:

If ComboBox1.SelectedItem.text = ComboBox1.Text Then

and look at the values of the variables being compared, you will have your answer.


I think the approach is wrong, you should look into the FindStringExact method. Think of it like you want to find out what you enter exists in the combo box and not what you entered (comboBox1.Text) is the same as you selected (ComboBox1.SelectedItem.text).

if (comboBox1.FindStringExact(comboBox1.Text) > -1) then


这篇关于如果不匹配组合框文本和组合列出的项目不匹配,如何显示消息?该消息是“未找到项目”。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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