Greg Robinson's Blog

I report it, you decide

Click Once

Custom Authentication in Windows Forms

DataBinding Stuff

Favorite Links

My book contribution

My Book Reviews

My Personal Life

Richmond, VA .NET Users Group

Smart Client Stuff

What I am reading

Setting ErrorProvider text on an 'invisible' control

I stumbled on this by mistake. I had a case where I was setting ErrorProviders text (calling SetError and passing in the control with text)  on a controls whose Visible property was set to True at runtime.

One would think you'd get an exception, but you do not.  The error provider is happy in this case.  So, as a work around I show a dialog if the control is not visible.

I know, why is a validated control not visible, long story.

 

PrivateSub SetCboSesErrorProviderValue(ByVal session As String)

If Me.IsConference AndAlso Me.LeaderIsAssignedToSession(session) Then

    ErrorProvider.SetError(Me.cboSes, "Leader is already assigned to session " & session & ".")

    If Not Me.cboSes.Visible Then

        AlertBox.Show(Me, Me._leaderName.Trim() & " has already been assigned as a leader to this event.", _

            "Leader Already Assigned to Event", Windows.Forms.MessageBoxButtons.OK, _

            Windows.Forms.MessageBoxIcon.Error)

    End If

Else

    ErrorProvider.SetError(Me.cboSes, "")

End If

End Sub ' SetCboSesErrorProviderValue

 

Comments

No Comments

Leave a Comment

(required) 

(required) 

(optional)

(required)