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

نام تاپیک: کمک فوری!! در باره autocomplete combobox

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

    کمک فوری!! در باره autocomplete combobox

    سلام...
    من با استفاده از راهنمایی دوستان یک combo box autocomplete درست کردم که کد اون رو اینجا آوردم.
    توی این combo نامهای خانوادگی هستند....حالا فرض کنید چند نفر به نام "امیری" وجود داشته باشند...من هر کدوم از اونهارو که انتخاب میکنم وقتی focouse از روی اون combo برداشته میشه مقدار combo به اولین امیری تغییر پیدا میکنه...به عبارت دیگه وقتی توی این کامبو مقدار تکراری وجوذد داشته باشه اون هر کاری که میکنم اولین عنصر اون مقدار انتخاب میشه...باید چیکار کنم؟اینم کد منه:
    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

  2. #2
    کاربر دائمی آواتار asilverisis
    تاریخ عضویت
    خرداد 1384
    محل زندگی
    اهواز
    پست
    262
    سلام
    حقیقتش من وقت نکردم کد رو نگاه کنم
    ولی اگه نیاز ت ضروریه می تونی از این استفاده کنی

    نحوه استفادش هم اینطوری که توی رویداد KeyUp هر combobox این تابع رو صدا بزنی

    با نام combobox و همون e رویداد
    فایل های ضمیمه فایل های ضمیمه

  3. #3
    کاربر تازه وارد
    تاریخ عضویت
    مرداد 1384
    محل زندگی
    Kermanshah
    پست
    87
    سلام دوست عزیز... یک دنیا ممنون...این کد خیلی به دردم خورد...فقط یه چیزی...میتونی بهم بگی چطوری میتونم توی این کامبوباکس 2-3 تا ستون بذارم؟...مرسی...

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

  1. در مورد خواصیت autocomplete در combobox کمک کنید
    نوشته شده توسط alih988 در بخش VB.NET
    پاسخ: 4
    آخرین پست: پنج شنبه 18 بهمن 1386, 07:06 صبح
  2. ComboBox - AutoComplete
    نوشته شده توسط جواد ملاولی در بخش بانک های اطلاعاتی در Delphi
    پاسخ: 3
    آخرین پست: دوشنبه 08 مرداد 1386, 20:54 عصر
  3. ComboBox با قابلیت AutoComplete
    نوشته شده توسط Mohammad_Mnt در بخش برنامه نویسی در Delphi
    پاسخ: 3
    آخرین پست: شنبه 21 آبان 1384, 15:28 عصر

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

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