We help IT Professionals succeed at work.
Get Started

Error Provider Function in VB 2005

cmdolcet
cmdolcet asked
on
213 Views
Last Modified: 2012-05-12
I have placed an error provider on my windows form. along with the error provider I have placed 5 combo boxes. In each select index change I have the code below. The problem I get into is if I change a combo box and it matches one currently selected it triggers the code below and catches the error and the warning. However if I dont fix the error and change a different combo box that error warning goes away.

Is there any way to control this or do I need to add an error provider for each combo box

Thanks in advance.
Private Sub cboPosition4_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboPosition4.SelectedIndexChanged 

If Me.cboPosition4.Text = Me.cboPosition1.Text Or Me.cboPosition4.Text = Me.cboPosition2.Text Or Me.cboPosition4.Text = Me.cboPosition3.Text Or Me.cboPosition4.Text = Me.cboPosition5.Text Then
            Me.btnSet.Enabled = False
            Me.btnSetDefault.Enabled = False
            Me.SetupError.SetError(Me.cboPosition4, "Please change the duplicate Position type.....")
        Else
            Me.btnSet.Enabled = True
            Me.btnSetDefault.Enabled = True
            Me.SetupError.Clear()
        End If

 End Sub

Open in new window

Comment
Watch Question
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014
Commented:
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE