Centar za edukaciju-BiH



#1 05.04.2019 12:36
xl_kid Van mreze
Clan
Registrovan od:11.11.2008
Postovi:154


Predmet:Combobox as you type
Pokušavam napraviti combobox da mi prikazuje samo vrednosti iz baze dok kucam.
Primer: u tabeli ima
ALGERIA
AUSTRALIA
AUSTRIA
ITALY
ST KITTS
ST LUCIA
UNITED STATES
ZAMBIA
ako u comboboxu unesem ST na mi prikaže sve gde ima taj kriterijum:
AUSTRALIA
AUSTRIA
ST KITTS
ST LUCIA
UNITED STATES
↑  ↓

#2 05.04.2019 16:25
Gjoreski Van mreze
Administrator
Registrovan od:02.02.2009
Postovi:1,854


Predmet:Re: Combobox as you type
PreuzmiIzvorni kôd (Visual Basic):
  1. Private Sub Form_Load()
  2.   Combo1.AllowAutoCorrect = False
  3.   Dim strSQL As String
  4.     strSQL = "SELECT * FROM tt WHERE Naziv Like '**'"
  5.    
  6.   Me.Combo1.RowSource = strSQL
  7.  
  8. End Sub
  9.  
  10. Private Sub Combo1_Change()
  11. Dim strSQL As String
  12.     strSQL = "SELECT * FROM tt WHERE Naziv Like '*" & Me.Combo1.Text & "*'"
  13.    
  14.   Me.Combo1.RowSource = strSQL
  15.   Me.Combo1.Dropdown
  16. End Sub
↑  ↓

#3 08.04.2019 09:58
xl_kid Van mreze
Clan
Registrovan od:11.11.2008
Postovi:154


Predmet:Re: Combobox as you type
vb je u pitanju. Ovo je izgleda za access.
Combo1.AllowAutoCorrect = False
Me.Combo1.RowSource = strSQL
Me.Combo1.Dropdown

prijavljuje mi greške
↑  ↓

#4 08.04.2019 11:28
Gjoreski Van mreze
Administrator
Registrovan od:02.02.2009
Postovi:1,854


Predmet:Re: Combobox as you type
ovo je access jel si trazio u access temama
za vb imamo vb tema
koja verzija vb koristis jeli vb6 ili vb.net
↑  ↓

#5 08.04.2019 12:03
xl_kid Van mreze
Clan
Registrovan od:11.11.2008
Postovi:154


Predmet:Re: Combobox as you type
vb.net
visual studio 2017
↑  ↓

#6 09.04.2019 10:54
Gjoreski Van mreze
Administrator
Registrovan od:02.02.2009
Postovi:1,854


Predmet:Re: Combobox as you type
Eve vidi dali ce raditi ova
PreuzmiIzvorni kôd (vbnet):
  1.     Private Sub cboArtikli_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs)
  2.         Dim rsArtikliBaraj = New ADODB.Recordset
  3.         Dim dtArtikliBaraj As New DataTable
  4.         Dim sqlBaraj As String
  5.         Dim i As Integer
  6.         sqlBaraj = "SELECT * FROM tblArtikli WHERE Artikal_Ime LIKE '%" & cboArtikli.Text & "%'"
  7.         'WHERE Description LIKE '%' + @SearchTerm + '%' AND Price <> '0.00'
  8.  
  9.         rsArtikliBaraj.Open(sqlBaraj, cn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic)
  10.         dtArtikliBaraj = RecordSetToDataTable(rsArtikliBaraj)
  11.  
  12.  
  13.  
  14.         '   Me.cboArtikli.DropDownStyle = ComboBoxStyle.DropDownList
  15.         '   Me.cboArtikli.AutoCompleteMode = AutoCompleteMode.None
  16.         '   Me.cboArtikli.AutoCompleteSource = AutoCompleteSource.None
  17.  
  18.         '        Me.cboArtikli.AllowDrop = True
  19.         Me.cboArtikli.DataSource = dtArtikliBaraj
  20.         '        Me.cboArtikli.DisplayMember = "Artikal_Ime"
  21.         '        Me.cboArtikli.ValueMember = "ID_Artikal"
  22.         Me.cboArtikli.Refresh()
  23.         Me.cboArtikli.DroppedDown = True
  24.         'Me.cboArtikli.DataBindings.Add("SelectedValue", dtArtikliBaraj, "Ed_Mera")
  25.  
  26.     End Sub
↑  ↓

#7 09.04.2019 11:58
xl_kid Van mreze
Clan
Registrovan od:11.11.2008
Postovi:154


Predmet:Re: Combobox as you type
Moja baza je MSSQL. Probao sam sa izmenama ali mi dozvoljava samo jedno slovo da upišem. Ali rezultata je dobar

*****
Private Sub nazivdm_combo_TextChanged(sender As Object, e As EventArgs) Handles nazivdm_combo.TextChanged

Dim strconn As String = "Data Source=10.10.60.83;Initial Catalog=INIT_DB;User ID=###;password=###"
Dim conn As New SqlConnection(strconn)
Dim cmd As New SqlCommand("SELECT Naziv FROM Kupci WHERE Naziv LIKE '%" & nazivdm_combo.Text & "%'", conn)
Dim da As New SqlDataAdapter(cmd)
Dim ds As New DataSet
da.Fill(ds, "List")
Dim col As New AutoCompleteStringCollection ' From which our names will come
Dim i As Integer
For i = 0 To ds.Tables(0).Rows.Count - 1
col.Add(ds.Tables(0).Rows(i)(0).ToString())
Next

'Dim rsArtikliBaraj = New ADODB.Recordset
'Dim dtArtikliBaraj As New DataTable
'Dim sqlBaraj As String
'Dim i As Integer
'sqlBaraj = "SELECT * FROM Kupci WHERE Naziv LIKE '%" & nazivdm_combo.Text & "%'"
'WHERE Description LIKE '%' + @SearchTerm + '%' AND Price <> '0.00'

'rsArtikliBaraj.Open(sqlBaraj, cn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic)
'dtArtikliBaraj = RecordSetToDataTable(rsArtikliBaraj)

'txtFirstName.Text = ds.Tables("AddressBook").Rows(0).Item(1)

'Me.nazivdm_combo.DropDownStyle = ComboBoxStyle.DropDownList
'Me.nazivdm_combo.AutoCompleteMode = AutoCompleteMode.None
'Me.nazivdm_combo.AutoCompleteSource = AutoCompleteSource.None

' Me.cboArtikli.AllowDrop = True
Me.nazivdm_combo.DataSource = col
' Me.nazivdm_combo.DisplayMember = "Naziv"
' Me.nazivdm_combo.ValueMember = "ID"
'Me.nazivdm_combo.Refresh()
'Me.nazivdm_combo.DroppedDown = True

'Me.cboArtikli.DataBindings.Add("SelectedValue", dtArtikliBaraj, "Ed_Mera")

End Sub
****

Sigurno sam negde pogrešio
↑  ↓

#8 10.04.2019 22:26
Gjoreski Van mreze
Administrator
Registrovan od:02.02.2009
Postovi:1,854


Predmet:Re: Combobox as you type
Nisi nigde pogresio problem je combo box
On je ogranicen sa mogucnosti pa resejne bi bilo megalomansko.
Jedan nacin da resis ovo je da uzmes neki drugi combo Box na primer DBCombo ili TDBCombo ili
ako neces koristiti neki drugi como box stavis text box i list box u kombinacija.

Razmisli pa javi
↑  ↓

#9 10.04.2019 23:15
zxz Van mreze
Administrator
Registrovan od:03.02.2009
Postovi:10,642


Predmet:Re: Combobox as you type
Neznam jeli ovo to sto trazis ali probaj p vidi.
U AutoCompleteMode odaberi SuggestAppend
a u
AutoCompleteSource ListItems
Podrska samo putem foruma, jer samo tako i ostali imaju koristi od toga.
↑  ↓

#10 11.04.2019 09:59
xl_kid Van mreze
Clan
Registrovan od:11.11.2008
Postovi:154


Predmet:Re: Combobox as you type
@zxz neće. hoću da kada unesem recimo "st" dobijem u listi AUSTRALIA, AUSTRIA, ST KITTS a kada nsatavim i dodam r (da bude str) lista tj odabir bude AUSTRALIA, AUSTRIA.

@Gjoreski pokuÅ¡aću textbox. ako imaÅ¡ neki primer bio bih i zahvalan
↑  ↓

Stranice (2):1,2


Sva vremena su GMT +01:00. Trenutno vrijeme: 1: 12 am.