问题描述
Hello Experts,
我的Windows窗体中有一个Textbox,Checked列表框和组合框。现在我必须让我的程序处于这样一个控制之中,应该输入这三个中的任何一个。例如,如果我输入文本框,我必须检查是否未选中组合框和选中的列表框。只有这样我才能运行我的功能。
这是我试过的东西
Hello Experts,
I have a Textbox, Checked listbox and Combo box in my windows form. Now I have to make my program in such a sway that, any one of these three should be entered. For example, If I enter Textbox, I have to check if Combo box and Checked Listbox are not selected. Only then I have to run my function.
Here is what I tried
If txtAccount.Text.ToString().Length() > 0 Then
If cmbProgram.SelectedItem.ToString().Length = 0 Or chkClasslist.SelectedItem.ToString().Length = 0 Then
Panel2.Visible = True
End If
我得到的Object引用未设置为实例...
有人可以帮助我实现我的req.?
And I get Object reference not set to instance...
Could someone help me to achieve my req.?
推荐答案
Try this!
If(txtAccount.Text<> String.Empty AndAlso cmbProgram.SelectedItem is Nothing AndAlso chkClasslist.SelectedItem is Nothing)orelse
(txtAccount.Text = String.Empty AndAlso cmbProgram.SelectedItem isNot Nothing AndAlso chkClasslist。 SelectedItem没什么)
orelse
(txtAccount.Text = String.Empty AndAlso cmbProgram.SelectedItem is什么AndOso chkClasslist.SelectedItem isNot Nothing)
然后
Panel2.Visible = True
结束如果
If (txtAccount.Text <> String.Empty AndAlso cmbProgram.SelectedItem is Nothing AndAlso chkClasslist.SelectedItem is Nothing) orelse
(txtAccount.Text = String.Empty AndAlso cmbProgram.SelectedItem isNot Nothing AndAlso chkClasslist.SelectedItem is Nothing)
orelse
(txtAccount.Text = String.Empty AndAlso cmbProgram.SelectedItem is Nothing AndAlso chkClasslist.SelectedItem isNot Nothing)
Then
Panel2.Visible = True
End If
这篇关于如何检查是否未选中组合框和选中的列表框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!