lakkadghat Posted January 8, 2004 Posted January 8, 2004 Hello The following code has been written to autofill combombox in my VB.NET Project. It works absolutely fine in some machines while it doesnt work at all in some machines. Does anyone have any idea. The problem is that inthe the comboboxautofill function it executes the if string=0 part. So it seems that in some machines it is not getting the string in the keypress event. but the event is being generated. Please help me to solve my problems. Private Sub Firstname_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Firstname.KeyPress fillcmb(Firstname, e) End Sub Private Sub fillcmb(ByRef cmbname As ComboBox, ByVal e As System.Windows.Forms.KeyPressEventArgs) Try Dim FindString As String If Asc(e.KeyChar) = Keys.Escape Then cmbname.SelectedIndex = -1 cmbname.Text = "" ElseIf Asc(e.KeyChar) = Keys.Back Then If cmbname.Text.Length > 0 Then ComboBoxAutoComplete(cmbname, cmbname.Text.Remove(cmbname.Text.Length - 1, 1)) End If Else ComboBoxAutoComplete(cmbname, cmbname.Text) End If e.Handled = True Catch ex As Exception MsgBox(ex.Message & "Error Filling combobox", MsgBoxStyle.Critical) End Try End Sub Private Sub ComboBoxAutoComplete(ByRef combo As ComboBox, ByVal str As String) Try Dim index As Integer If str.Length = 0 Then combo.SelectedIndex = -1 'combo.Text = "" combo.Text = combo.Text Else index = combo.FindString(str) If index <> -1 Then combo.SelectedIndex = index combo.SelectionStart = str.Length combo.SelectionLength = combo.Text.Length - combo.SelectionStart End If End If Catch ex As Exception MsgBox(ex.Message & "Error ComboAutocomplete Event", MsgBoxStyle.Critical) End Try End Sub Quote
Administrators PlausiblyDamp Posted January 8, 2004 Administrators Posted January 8, 2004 http://www.xtremedotnettalk.com/showthread.php?s=&threadid=81380 has a couple of suggestions in it. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
lakkadghat Posted January 15, 2004 Author Posted January 15, 2004 Thanx for your reply. It really helped me out and fixed my bug too thanx a lot Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.