.:: Jasa Membuat Aplikasi Website,Desktop,Android Order Now..!! | | Order Now..!! Jasa Membuat Project Arduino,Robotic,Print 3D ::.

Auto complete in Combo Box on Visual Basic .Net

0 komentar


بِسْــــــــــــــــمِ اﷲِالرَّحْمَنِ اارَّحِيم
bismillaahirrahmaanirrahiim

السَّلاَمُ عَلَيْكُمْ وَرَحْمَةُ اللهِ وَبَرَكَاتُهُ
Assalamu'alaikum warahmatullahi wabarakatuh


The Windows Forms ComboBox control is used to display data in a drop-down combo box. By default, the ComboBox control appears in two partsthe top part is a text box that allows the user to type a list item. The second part is a list box that displays a list of items from which the user can select one.
�Sample code on how to create a auto complete box on visual basic .net 
Private Sub cboName_Leave(ByVal sender As Object, ByVal e As System.EventArgs)
Handles cboName.Leave

Dim recRowView As DataRowView

Dim recName As DB.tblNameRow
AutoCompleteCombo_Leave(cboName)

�OPTIONAL: Now you can do some extra handling if you want

�Get the Selected Record from my Data Bound Combo (Return Type is DataRowView)
recRowView = cboName.SelectedItem

If recRowView Is Nothing Then Exit Sub

�Display the Name Info (Row Type comes from my bound Dataset)
recName = recRowView.Row
lblAccountNum.Text = recName.AccountNum
lblCompanyName.Text = recName.CompanyName
End Sub
Private Sub cboName_KeyUp(ByVal sender As Object,
ByVal e As System.Windows.Forms.KeyEventArgs) Handles cboName.KeyUp
AutoCompleteCombo_KeyUp(cboName, e)
End Sub
�Here are the Generic Functions for handling the events:
Public Sub AutoCompleteCombo_KeyUp(ByVal cbo As ComboBox, ByVal e As KeyEventArgs)

Dim sTypedText As String

Dim iFoundIndex As Integer

Dim oFoundItem As Object

Dim sFoundText As String

Dim sAppendText As String

�Allow select keys without Autocompleting
Select Case e.KeyCode

Case Keys.Back, Keys.Left, Keys.Right, Keys.Up, Keys.Delete, Keys.Down

Return

End Select

�Get the Typed Text and Find it in the list
sTypedText = cbo.Text
iFoundIndex = cbo.FindString(sTypedText)

�If we found the Typed Text in the list then Autocomplete

If iFoundIndex >= 0 Then

�Get the Item from the list (Return Type depends if Datasource was bound

� or List Created)
oFoundItem = cbo.Items(iFoundIndex)

�Use the ListControl.GetItemText to resolve the Name in case the Combo

� was Data bound
sFoundText = cbo.GetItemText(oFoundItem)

�Append then found text to the typed text to preserve case
sAppendText = sFoundText.Substring(sTypedText.Length)
cbo.Text = sTypedText & sAppendText

�Select the Appended Text
cbo.SelectionStart = sTypedText.Length
cbo.SelectionLength = sAppendText.Length

End If
End Sub
Public Sub AutoCompleteCombo_Leave(ByVal cbo As ComboBox)

Dim iFoundIndex As Integer
iFoundIndex = cbo.FindStringExact(cbo.Text)
cbo.SelectedIndex = iFoundIndex
End Sub

Update Contact :
No Wa/Telepon (puat) : 085267792168
No Wa/Telepon (fajar) : 085369237896
Email : Fajarudinsidik@gmail.com
NB :: Bila Sobat tertarik Ingin membuat software, membeli software, membeli source code, membeli hardware elektronika untuk kepentingan Perusahaan maupun Tugas Akhir (TA/SKRIPSI), Insyaallah Saya siap membantu, untuk Respon Cepat dapat menghubungi kami, melalui :

No Wa/Telepon (puat) : 085267792168
No Wa/Telepon (fajar) : 085369237896
Email: Fajarudinsidik@gmail.com


atau Kirimkan Private messanger melalui email dengan klik tombol order dibawah ini :

ٱلْحَمْدُ لِلَّهِ رَبِّ ٱلْعَٰلَمِين
Alhamdulilah hirobil alamin

وَ السَّلاَمُ عَلَيْكُمْ وَرَحْمَةُ اللهِ وَبَرَكَاتُهُ
wassalamualaikum warahmatullahi wabarakatuh


Artikel Auto complete in Combo Box on Visual Basic .Net, Diterbitkan oleh scodeaplikasi pada Sabtu, 05 November 2011. Semoga artikel ini dapat menambah wawasan Anda. Website ini dipost dari beberapa sumber, bisa cek disini sumber, Sobat diperbolehkan mengcopy paste / menyebar luaskan artikel ini, karena segala yang dipost di public adalah milik public. Bila Sobat tertarik Ingin membuat software, membeli software, membeli source code ,Dengan Cara menghubungi saya Ke Email: Fajarudinsidik@gmail.com, atau No Hp/WA : (fajar) : 085369237896, (puat) : 085267792168.

Tawk.to