بسم الله الرحمن الرحيم
==============
الأخوة الكرام
تحية طيبة وبعد ،،،
الكل يعلم أن ال Combo Box فى الاكسيس يقوم بالتكملة التلقائية للحروف عند الكتابة فيه لإختيار العنصر
وسؤالى هو كيف يتم ذلك فى الفيجوال بيسك دوت نت
تقبلوا تحياتى
بسم الله الرحمن الرحيم
==============
الأخوة الكرام
تحية طيبة وبعد ،،،
الكل يعلم أن ال Combo Box فى الاكسيس يقوم بالتكملة التلقائية للحروف عند الكتابة فيه لإختيار العنصر
وسؤالى هو كيف يتم ذلك فى الفيجوال بيسك دوت نت
تقبلوا تحياتى
لتكملة النص بصورة تلقائية في ال Combo Box يجب أن تستخدم الشفرة لعمل ذلك , الاجراء التالي يستخدم لما تطلبه ولكي تستطيع إستخدامه علي مستوي التطبيق يدون ان تقوم بالاعلان عن الكائنات و و و , قم بانشاء Module جديد في المشروع واكتب فيه الشفرة التالية :
Public Sub AutoCompleteKeyUp(ByVal Combo As ComboBox, _ ByVal e As KeyEventArgs) Dim strTyped As String Dim intFoundIndex As Integer Dim objFoundItem As Object Dim strFoundText As String Dim strAppendText As String ' Ignore basic selection keys Select Case e.KeyCode Case Keys.Back, Keys.Left, Keys.Right, Keys.Up, _ Keys.Delete, Keys.Down, Keys.CapsLock Return End Select ' Find what user has typed in list strTyped = Combo.Text intFoundIndex = Combo.FindString(strTyped) ' If found... If intFoundIndex >= 0 Then ' Get list item (actual type depends on whether data bound) objFoundItem = Combo.Items(intFoundIndex) ' Use control to resolve text - in case data bound strFoundText = Combo.GetItemText(objFoundItem) ' Append the typed text to rest of the found string ' (text is set twice due to a combo box quirk: ' on certain platforms, setting just once ignores casing!) strAppendText = strFoundText.Substring(strTyped.Length) Combo.Text = strTyped & strAppendText Combo.Text = strTyped & strAppendText ' Select the appended text Combo.SelectionStart = strTyped.Length Combo.SelectionLength = strAppendText.Length End If End Sub
ولاستخدام هذا الاجراء للتكملة التلقائية قم بمناداته بالشكل التالي :
* بافتراض ان كائن ال Combo اسمه ComboBox1
Private Sub ComboBox1_KeyUp(ByVal sender As Object, _ ByVal e As System.Windows.Forms.KeyEventArgs) Handles ComboBox1.KeyUp AutoCompleteKeyUp(ComboBox1, e) End Sub
والله الموفق
بارك الله فيك ، معلومة فعلا جميلة
فلسطين الزاهية بألوان الحب والسلام
ذلك الطعم الزيتوني الذي يتدفق عسلاً من أفواه بساتينها وحدائقها
تشتاق إليها نفوس المتقين وترنوا للسجود فيها جباه المسلمين
السلام عليكم ورحمة الله وبركاته
===================
شكرا أخى الكريم على ردكم
ولكن عندما قمت بتنفيذ ذلك لم تتم التكملة التلقائية لجميع الكلمة
فهل من الممكن إرفاق مثال على ذلك فقد يكون الخطأ عندى
ملحوظة أستخدم نسخة 2002
وجزاك الله خيرا
السلام عليكم ورحمة الله وبركاته
==================
جزاك الله خيرا أخى الكريم
ولكنى عندما غيرت خاصية DropDownStyle الى DropDownList لم تتم التكملة التلقائية
وأنا أريد العمل مع تلك الخاصية وأريد التكملة التلقائية فما هو الحل
تقبلوا تحياتى
السلام عليكم
ربما هذا الحل يجدي .. ربما لا ... على حسب الطلب لكن حاول تبقى هي محاولة فقط
Private Sub cb3_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cb3.TextChanged cb3.DropDownStyle = ComboBoxStyle.DropDown CBox.TChanage(sender, e) End Sub Private Sub cb3_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles cb3.MouseDown cb3.DropDownStyle = ComboBoxStyle.DropDownList End Sub Private Sub cb3_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles cb3.MouseEnter cb3.DropDownStyle = ComboBoxStyle.DropDown End Sub Private Sub cb3_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles cb3.MouseLeave cb3.DropDownStyle = ComboBoxStyle.DropDownList End Sub
السلام عليكم
في المثال يتضح المقال
هذا الموضوع مغلق.