Reputation: 729
I'm Trying use the bunifu textbox in the lost focus event but cause errorprovider not being able to stop in VB.NET.
If I move from a Bunifu TextBox control to a standard TextBox control, it makes the textBox seem to move and I use the lostfocus event in the Bunifu TextBox so that the error provider can't stop if I run in the standard textbox then it runs normally
is there something wrong with my code?
Please Guide Me.
Thanks
Public Class Form3
Dim TestAutoComplete As New AutoCompleteStringCollection
Private Sub Form3_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.BunifuTextBox1.AutoCompleteMode = AutoCompleteMode.SuggestAppend
Me.BunifuTextBox1.AutoCompleteSource = AutoCompleteSource.CustomSource
Me.TextBox1.AutoCompleteMode = AutoCompleteMode.SuggestAppend
Me.TextBox1.AutoCompleteSource = AutoCompleteSource.CustomSource
TestAutoComplete.Add("Mahesh Chand")
TestAutoComplete.Add("Mac Jocky")
TestAutoComplete.Add("Millan Peter")
BunifuTextBox1.AutoCompleteCustomSource = TestAutoComplete
End Sub
Private Sub BunifuTextBox1_TextChanged(sender As Object, e As EventArgs) Handles BunifuTextBox1.TextChanged
If String.IsNullOrEmpty(BunifuTextBox1.Text) Then
ErrorProvider1.SetError(BunifuTextBox1, "")
Else
If TestAutoComplete.Count > 0 Then
ErrorProvider1.SetError(BunifuTextBox1, "")
End If
End If
End Sub
Private Sub BunifuTextBox1_LostFocus(sender As Object, e As EventArgs) Handles BunifuTextBox1.LostFocus
TestAutoComplete.Add("Mahesh Chand")
TestAutoComplete.Add("Mac Jocky")
TestAutoComplete.Add("Millan Peter")
BunifuTextBox1.AutoCompleteCustomSource = TestAutoComplete
If BunifuTextBox1.Text = "C" And BunifuTextBox1.Text <> "" Then
ErrorProvider1.SetError(BunifuTextBox1, "Name still doesn't match")
MsgBox("Name still doesn't match")
Application.DoEvents()
BunifuTextBox1.SelectionStart = 0
BunifuTextBox1.SelectionLength = BunifuTextBox1.Text.Length
BunifuTextBox1.Select()
End If
End Sub
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
If String.IsNullOrEmpty(TextBox1.Text) Then
ErrorProvider1.SetError(TextBox1, "")
Else
If TestAutoComplete.Count > 0 Then
ErrorProvider1.SetError(TextBox1, "")
End If
End If
End Sub
Private Sub TextBox1_LostFocus(sender As Object, e As EventArgs) Handles TextBox1.LostFocus
TestAutoComplete.Add("Mahesh Chand")
TestAutoComplete.Add("Mac Jocky")
TestAutoComplete.Add("Millan Peter")
TextBox1.AutoCompleteCustomSource = TestAutoComplete
If TextBox1.Text = "C" And TextBox1.Text <> "" Then
ErrorProvider1.SetError(TextBox1, "Name still doesn't match")
MsgBox("Name still doesn't match")
Application.DoEvents()
TextBox1.SelectionStart = 0
TextBox1.SelectionLength = TextBox1.Text.Length
TextBox1.Select()
End If
End Sub
End Class
RESULT WITH BUNIFU TEXTBOX
RESULT WITH STANDARD TEXTBOX
Upvotes: 0
Views: 39