|
-
Oct 5th, 2011, 10:07 AM
#1
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,...
-
Oct 5th, 2011, 10:35 AM
#2
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:
Private Sub DataGridView1_EditingControlShowing(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) Handles DataGridView1.EditingControlShowing
Dim Role As String = e.Control.AccessibilityObject.Role.ToString()
Select Case Role
Case "ComboBox"
Dim cbo As ComboBox = TryCast(e.Control, ComboBox)
Exit Select
Case "Text"
If Me.DataGridView1.CurrentCell.ColumnIndex = 0 Then
Dim txt As TextBox = TryCast(e.Control, TextBox)
If txt IsNot Nothing Then
If _ModuleAutoCompleteSuggestion IsNot Nothing Then
Array.Sort(_ModuleAutoCompleteSuggestion)
txt.AutoCompleteCustomSource.Clear()
txt.AutoCompleteCustomSource.AddRange(_ModuleAutoCompleteSuggestion)
txt.AutoCompleteSource = AutoCompleteSource.CustomSource
txt.AutoCompleteMode = AutoCompleteMode.Suggest
End If
End If
End If
Exit Select
End Select
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,...
-
Oct 5th, 2011, 10:58 AM
#3
Addicted Member
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"
-
Oct 5th, 2011, 10:59 AM
#4
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:
'~~~ Class level declaration
Dim AutoCompleteSuggestions() As String = {"1211", "123", "215", "1256", "123354"}
'...
'.....
'......
'~~~ AutoSuggestion
Private Sub DataGridView1_EditingControlShowing(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) Handles DataGridView1.EditingControlShowing
Dim Role As String = e.Control.AccessibilityObject.Role.ToString()
Select Case Role
Case "ComboBox"
Dim cbo As ComboBox = TryCast(e.Control, ComboBox)
Exit Select
Case "Text"
If Me.DataGridView1.CurrentCell.ColumnIndex = 0 Then
Dim txt As TextBox = TryCast(e.Control, TextBox)
If txt IsNot Nothing Then
If AutoCompleteSuggestions IsNot Nothing Then
Array.Sort(AutoCompleteSuggestions)
txt.AutoCompleteCustomSource.Clear()
txt.AutoCompleteCustomSource.AddRange(AutoCompleteSuggestions)
txt.AutoCompleteSource = AutoCompleteSource.CustomSource
txt.AutoCompleteMode = AutoCompleteMode.Suggest
End If
End If
End If
Exit Select
End Select
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,...
-
Oct 5th, 2011, 11:05 AM
#5
Re: Auto suggest and display corresponding details of id entered
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,...
-
Oct 5th, 2011, 01:40 PM
#6
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,...
-
Oct 7th, 2011, 01:16 AM
#7
Addicted Member
Re: Auto suggest and display corresponding details of id entered
-
Oct 7th, 2011, 01:28 AM
#8
Re: Auto suggest and display corresponding details of id entered
 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|