نمایش نتایج 1 تا 13 از 13

نام تاپیک: فیلترینگ در combobox

  1. #1

    فیلترینگ در combobox

    من چند روز پیش پروژه از پایگاه داده ام رو تحویل دادم استادم حال کرد.
    اما چند تا ایراد گرفت که یکی از ان این بود که در پروژه ثبت نام و انتخاب واحد دانشگاه نام دانشجو نباید Textbox
    باشد و باید از Combobox استفاده کنند
    بدین صورت که در ابتدا مثلا 30 دانشجوی نخست را نشان دهد و ان را فیلتر کند بهد با تایپ یک حرف 30 دانشجوی که نام انها با ان حرف
    شروع می شود فیلتر کند و جایگزین کند و خلاصه با تایپ هر حرف به هدف نزدیکتر شود

    این کار شدنی است (نگید که نمیشه ) چون استاد مادر پروژه vb6 این کارو کرده ولی کد ان در اختیار من نیست .

    حالا شما کمک کنید و این مشکل را حل کنید.
    ممنون

  2. #2
    کاربر دائمی
    تاریخ عضویت
    بهمن 1381
    محل زندگی
    تهران
    پست
    240
    کار ساده ای فقط تو VB6 میخوای یا VB.NET ؟

  3. #3
    vb.net

    ببین اگر کدش زیاده mail بدم فایل شو میل کن

    ممنون

  4. #4
    کاربر دائمی
    تاریخ عضویت
    آذر 1382
    محل زندگی
    gh_fereydonpoor@yahoo.com
    پست
    198
    سلام
    میتونی از Event ، TextChange استفاده کنی و هرباز که اتفاق می افته 30 تا رکورد بخونی و Bind کنی شون به Comboboxe

  5. #5
    سلام

    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


  6. #6
    سلام
    یا من منظورم را درست نرساندم یا شما اشتباه برداشت کرده اید
    من می خوام مثلا اگر حرف c
    رو فشار داد کامبو باکس باز شده و ایتم هایی که با حرف c
    شروع می شوند نشان داده شود تا از این لیست فیلتر شده یکی را انتخاب کند

    ولی باز هم ممنون زحمت کشیدید کد رو در اختیار من قرار دادید
    با تشکر

  7. #7
    ببین اینا بدرد میخورن

    http://rr.exhedra.com/Upload_PSC/ftp...9712182003.zip
    http://rr.exhedra.com/upload_PSC/ftp...8584172002.zip

    یا

    Module Module1
    Public Sub AutoComplete(ByVal cbo As ComboBox, ByVal e As System.Windows.Forms.KeyEventArgs)
    'call this from your form passing in the name of your combobox and the event arg:
    'AutoComplete(cboState, e)
    Dim iIndex As Integer
    Dim sActual As String
    Dim sFound As String
    Dim bMatchFound As Boolean
    'if backspace then remove the last character that was typed in and try to find a match.
    'note that the selected text from the last character typed in to the end of the combo text field will also be deleted.
    If e.KeyCode = Keys.Back Then
    cbo.Text = Mid(cbo.Text, 1, Len(cbo.Text) - 1)
    End If
    ' Do nothing for some keys such as navigation keys.
    If ((e.KeyCode = Keys.Left) Or _
    (e.KeyCode = Keys.Right) Or _
    (e.KeyCode = Keys.Up) Or _
    (e.KeyCode = Keys.Down) Or _
    (e.KeyCode = Keys.PageUp) Or _
    (e.KeyCode = Keys.PageDown) Or _
    (e.KeyCode = Keys.Home) Or _
    (e.KeyCode = Keys.End)) Then
    Return
    End If
    Do
    ' Store the actual text that has been typed.
    sActual = cbo.Text
    ' Find the first match for the typed value.
    iIndex = cbo.FindString(sActual)
    ' Get the text of the first match.
    'if index > -1 then a match was found.
    If (iIndex > -1) Then
    sFound = cbo.Items(iIndex).ToString()
    ' Select this item from the list.
    cbo.SelectedIndex = iIndex
    ' Select the portion of the text that was automatically
    ' added so that additional typing will replace it.
    cbo.SelectionStart = sActual.Length
    cbo.SelectionLength = sFound.Length
    bMatchFound = True
    Else
    'if there isn't a match and the text typed in is only 1 character or nothing then just select the first
    'entry in the combo box.
    If sActual.Length = 1 Or sActual.Length = 0 Then
    cbo.SelectedIndex = 0
    cbo.SelectionStart = 0
    cbo.SelectionLength = Len(cbo.Text)
    bMatchFound = True
    Else
    'if there isn't a match for the text typed in then remove the last character of the text typed in
    'and try to find a match.
    cbo.SelectionStart = sActual.Length - 1
    cbo.SelectionLength = sActual.Length - 1
    cbo.Text = Mid(cbo.Text, 1, Len(cbo.Text) - 1)
    End If
    End If
    Loop Until bMatchFound
    End Sub
    End Module

  8. #8
    سلام
    ممنون
    بعدا اونا رو نگاه می کنم و تست می کنم
    عید شما مبارک sh
    سال خوبی داشته باشید
    پیروز و سربلند باشید
    :wink: :wink:

  9. #9
    کاربر تازه وارد
    تاریخ عضویت
    مرداد 1384
    محل زندگی
    Kermanshah
    پست
    87
    سلام...
    من با استفاده از راهنمایی شما یک combo box autocomplete درست کردم
    توی این combo نامهای خانوادگی هستند....حالا فرض کنید چند نفر به نام "امیری" وجود داشته باشند...من هر کدوم از اونهارو که انتخاب میکنم وقتی focouse از روی اون combo برداشته میشه مقدار combo به اولین امیری تغییر پیدا میکنه...به عبارت دیگه وقتی توی این کامبو مقدار تکراری وجود داشته باشه فقط اولین عنصر اون مقدار انتخاب میشه...باید چیکار کنم؟

  10. #10
    ببین دوست من وقتی شما مثلا امیری رو وارد می کنی خوب لیست امیریها می آید بعدش چی می خواهی بشه روی اولین امیری وایمیسه .

  11. #11
    کاربر تازه وارد
    تاریخ عضویت
    مرداد 1384
    محل زندگی
    Kermanshah
    پست
    87
    بله روی اولین امیری وایمیسه.... ولی اگه من چهارمین امیری رو انتخاب کنم و focus رو از اون کنترل بگیرم باز هم روی اولین امیری وایمیسه و نه روی چهارمین امیری که من انتخابش کرده بودم...

  12. #12
    چون درون دیتابیست پرشی انجام نمیشه . این پرش رو در قسمت دیتابیست انجام بده نه در قسمت اینتر فیس COMBO ببین اطلاعات درون دیتابیس رو مثلا بر حسب چهار حرف اول فامیل سورت کن . با تغییر مقدار یک TEXTBOX مخفی درون فرم مقدار اون تکست باکس رو درون دیتابیس سرچ کن و اون رو استفاده کن . جیگر

  13. #13
    کاربر تازه وارد
    تاریخ عضویت
    مرداد 1384
    محل زندگی
    Kermanshah
    پست
    87
    ممنون از راهنمایت... من فکر میکنم بتونم از طریق شی binding context پرش رو انجام بدم...اما نمیدونم چطوری با داشتن مقدار یک فیلد میشه به رکورد مورد نظر seek کرد میشه راهنماییم کنی؟

تاپیک های مشابه

  1. بایند کردن combobox
    نوشته شده توسط Mrs.Net در بخش C#‎‎
    پاسخ: 12
    آخرین پست: جمعه 06 مهر 1386, 12:09 عصر
  2. اضافه کردن ایتم به combobox
    نوشته شده توسط jafari_m246 در بخش C#‎‎
    پاسخ: 9
    آخرین پست: چهارشنبه 17 مرداد 1386, 16:42 عصر
  3. مشکل دوم ComboBox
    نوشته شده توسط lililili در بخش Access
    پاسخ: 8
    آخرین پست: سه شنبه 19 تیر 1386, 10:22 صبح

قوانین ایجاد تاپیک در تالار

  • شما نمی توانید تاپیک جدید ایجاد کنید
  • شما نمی توانید به تاپیک ها پاسخ دهید
  • شما نمی توانید ضمیمه ارسال کنید
  • شما نمی توانید پاسخ هایتان را ویرایش کنید
  •