如何比较组合框所选项目与文本框值 [英] how to compare combobox selected item with textbox value

查看:58
本文介绍了如何比较组合框所选项目与文本框值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何比较组合框所选项目与文本框值

解决方案

我想你想要比较什么?组合框选择值或组合框选择文本?



如果比较文本试试这个:



 如果 combobox1.selecteditem.text = txtname.text  

else

end 如果





如果比较价值,试试这个:

 如果 combobox1.selectedvalue = txtname.text  

else

end if


 如果  字符串 .IsNullOrWhiteSpace(ComboBox1.Text)  字符串 .IsNullOrWhiteSpace(TextBox1.Text)然后 
如果 ComboBox.Text = TextBox.Text 那么
MsgBox( 匹配
否则
MsgBox( 不匹配
结束 如果
结束 如果


尝试这样: -



  private   void  comboBox1_SelectedIndexChanged( object  sender,EventArgs e) 
{

if (comboBox1.SelectedItem.ToString()== txtName.Text)
{
// 在这里做点什么
}
else
{
// 在这里做点什么
}
}


how to compare combobox selected item with textbox value

解决方案

I would think what are you trying to compare? the combobox selected value or combobox selected text?

if comparing the text try this:

if combobox1.selecteditem.text = txtname.text then

else

end if



if comparing the value try this:

if combobox1.selectedvalue = txtname.text then

else

end if


If Not String.IsNullOrWhiteSpace(ComboBox1.Text) And Not String.IsNullOrWhiteSpace(TextBox1.Text) Then
            If ComboBox.Text = TextBox.Text Then
                MsgBox("Match")
            Else
                MsgBox("Not Match")
            End If
End If


try like this:-

private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
       {

           if (comboBox1.SelectedItem.ToString() == txtName.Text)
           {
               //do something here
           }
           else
           {
               //do something here
           }
       }


这篇关于如何比较组合框所选项目与文本框值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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