Results 1 to 8 of 8

Thread: Auto suggest and display corresponding details of id entered

  1. #1

    Thread Starter
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Question Auto suggest and display corresponding details of id entered

    Hi guys

    I have previously asked a questions regarding DataGridView control: http://www.vbforums.com/showthread.php?t=661859

    Now I'm trying to make the first column to include an autosuggestion. ie. when a user types an ID(say, "12") then all the records that starts with it(ie. "12*") will be displayed as suggestion.

    And upon clicking an ID, the corresponding product_name will be displayed on the next column. I think, I could do this using Validating() event of DataGridView.

    But how would I add the autosuggestion for the first column ?

    Thanks

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  2. #2

    Thread Starter
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: Auto suggest and display corresponding details of id entered

    Found this thread: http://www.vbforums.com/showthread.php?t=590762
    And converted the code using Telerik Code Converter:

    vb.net Code:
    1. Private Sub DataGridView1_EditingControlShowing(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) Handles DataGridView1.EditingControlShowing
    2.         Dim Role As String = e.Control.AccessibilityObject.Role.ToString()
    3.         Select Case Role
    4.             Case "ComboBox"
    5.                 Dim cbo As ComboBox = TryCast(e.Control, ComboBox)
    6.  
    7.                 Exit Select
    8.  
    9.             Case "Text"
    10.  
    11.                 If Me.DataGridView1.CurrentCell.ColumnIndex = 0 Then
    12.                     Dim txt As TextBox = TryCast(e.Control, TextBox)
    13.                     If txt IsNot Nothing Then
    14.                         If _ModuleAutoCompleteSuggestion IsNot Nothing Then
    15.                             Array.Sort(_ModuleAutoCompleteSuggestion)
    16.                             txt.AutoCompleteCustomSource.Clear()
    17.                             txt.AutoCompleteCustomSource.AddRange(_ModuleAutoCompleteSuggestion)
    18.                             txt.AutoCompleteSource = AutoCompleteSource.CustomSource
    19.                             txt.AutoCompleteMode = AutoCompleteMode.Suggest
    20.  
    21.                         End If
    22.                     End If
    23.                 End If
    24.                 Exit Select
    25.         End Select
    26.     End Sub
    It's showing an error on the AccessibilityObject line:
    Code:
    Error	1	Reference required to assembly 'Accessibility, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' containing the implemented interface 'Accessibility.IAccessible'. Add one to your project.
    Any ideas ?

    Thanks

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  3. #3
    Addicted Member
    Join Date
    Nov 2010
    Location
    TamilNadu, India
    Posts
    249

    Re: Auto suggest and display corresponding details of id entered

    add this file as a reference.....
    "C:\Windows\Microsoft.NET\Framework\v2.0.50727\Accessibility.dll"

  4. #4

    Thread Starter
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: Auto suggest and display corresponding details of id entered

    Added reference to the Accessibility and that error is resolved.

    Code tested:
    vb.net Code:
    1. '~~~ Class level declaration
    2. Dim AutoCompleteSuggestions() As String = {"1211", "123", "215", "1256", "123354"}
    3. '...
    4. '.....
    5. '......
    6.  
    7. '~~~ AutoSuggestion
    8.     Private Sub DataGridView1_EditingControlShowing(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) Handles DataGridView1.EditingControlShowing
    9.         Dim Role As String = e.Control.AccessibilityObject.Role.ToString()
    10.         Select Case Role
    11.             Case "ComboBox"
    12.                 Dim cbo As ComboBox = TryCast(e.Control, ComboBox)
    13.  
    14.                 Exit Select
    15.  
    16.             Case "Text"
    17.  
    18.                 If Me.DataGridView1.CurrentCell.ColumnIndex = 0 Then
    19.                     Dim txt As TextBox = TryCast(e.Control, TextBox)
    20.                     If txt IsNot Nothing Then
    21.                         If AutoCompleteSuggestions IsNot Nothing Then
    22.                             Array.Sort(AutoCompleteSuggestions)
    23.                             txt.AutoCompleteCustomSource.Clear()
    24.                             txt.AutoCompleteCustomSource.AddRange(AutoCompleteSuggestions)
    25.                             txt.AutoCompleteSource = AutoCompleteSource.CustomSource
    26.                             txt.AutoCompleteMode = AutoCompleteMode.Suggest
    27.  
    28.                         End If
    29.                     End If
    30.                 End If
    31.                 Exit Select
    32.         End Select
    33.     End Sub

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  5. #5

    Thread Starter
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: Auto suggest and display corresponding details of id entered

    Quote Originally Posted by medsont View Post
    add this file as a reference.....
    "C:\Windows\Microsoft.NET\Framework\v2.0.50727\Accessibility.dll"
    Thanks

    Already figured it out.

    Now, the suggestions combobox is showing. But upon selecting an item from it(double clicking) it just add to the first column and moves to the next record. Which was supposed to be moved onto the next column. But when pressing the tab button(while an item from the combobox is selected - single click) will save the selected item in first column and move onto the next column.

    Any ideas on how to resolve it ?


    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  6. #6

    Thread Starter
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: Auto suggest and display corresponding details of id entered

    Another question:
    I didn't got the idea of this line:
    Code:
    Dim Role As String = e.Control.AccessibilityObject.Role.ToString()
    Can anyone tell me what it does ?

    Thanks

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  7. #7
    Addicted Member
    Join Date
    Nov 2010
    Location
    TamilNadu, India
    Posts
    249

    Re: Auto suggest and display corresponding details of id entered


  8. #8

    Thread Starter
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: Auto suggest and display corresponding details of id entered

    Quote Originally Posted by http://msdn.microsoft.com/en-us/library/system.windows.forms.accessibleobject(v=VS.71).aspx

    Provides information that accessibility applications use to adjust an application's UI for users with impairments.

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width