473,770 Members | 2,004 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

AutoComplete in datagridviewtex tboxcolumn not working

I try to implement a AutoComplete function to the datagridviewtex tboxcolumn
to a Datagridview control with several others datagridviewtex tboxcolumns.
This function is meant to apply to the column, CustomerID, in the
datagridview control. However the AutoComplete function occurs on EVERY
datagridviewtex tbox column with the same datatype - string. For example the
function should be at the CustomerID column which has the column index =1,
however the function is appeared on columns, Ship Name, ShipAddress, ShipCity
and ShipRegion, where the datatype is string.

Here is the code I found at
http://www.vb-tips.com/DataGridViewAutoComplete.aspx

and I created the sample datagridview control to test the function:

DataGridView: Auto Complete Textbox

In the datagridview's editing control showing event you have better access
to the textboxes properties. Here is an example of adding autocomplete to
the textbox.

Imports System.Data.Sql Client

Public Class Form1

Dim scAutoComplete As New AutoCompleteStr ingCollection

Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Dim strConn As String
Dim da As SqlDataAdapter
Dim conn As SqlConnection
Dim ds As New DataSet
strConn = "Server = .;Database = NorthWind; Integrated Security =
SSPI;"
conn = New SqlConnection(s trConn)
da = New SqlDataAdapter( "Select * from [Orders]", conn)
da.Fill(ds, "Orders")
DataGridView1.D ataSource = ds.Tables("Orde rs")

Dim cmd As New SqlCommand("Sel ect CustomerID From customers", conn)
Dim dr As SqlDataReader

conn.Open()
dr = cmd.ExecuteRead er
Do While dr.Read
scAutoComplete. Add(dr.GetStrin g(0))
Loop
conn.Close()
End Sub

Private Sub DataGridView1_E ditingControlSh owing(ByVal sender As Object,
ByVal e As System.Windows. Forms.DataGridV iewEditingContr olShowingEventA rgs)
Handles DataGridView1.E ditingControlSh owing
If DataGridView1.C urrentCell.Colu mnIndex = 1 AndAlso TypeOf
e.Control Is TextBox Then
With DirectCast(e.Co ntrol, TextBox)
.AutoCompleteMo de = AutoCompleteMod e.SuggestAppend
.AutoCompleteSo urce = AutoCompleteSou rce.CustomSourc e
.AutoCompleteCu stomSource = scAutoComplete
End With
End If
End Sub
End Class

Thanks

Jun 27 '08 #1
0 2125

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

40
10899
by: Alex | last post by:
Hello, does anybody know how to turn off the autocomplete feature for a certain text field? I am aware of the "autocomplete" attribute, but I have seen other implementions achieving it without any such attribute and am wondering whether there is another way to do it .... like via CSS or a naming convention or .......
4
2077
by: Noah Coad [MVP .NET/C#] | last post by:
For no appearnt reason, the AutoComplete stopped showing me the members of a number of classes used in my project. It was working just fine, and as of yeasterday, AutoComplete stopped working. It works with some classes, but not others. I didn't change anything that should effect this. The classes also don't show up anymore under the 'Class View' and I can't navigate to the definition using the keyboard hotkey. It still works for all...
0
1788
by: venu | last post by:
Hi All I need some help from u guys. iam working on aspx page.in this page i have lot fields. text boxes and dropdown lists .. First filed should be a autocomplete filed. this text has onblur event also based on this text box when onblur event is fired that time other fields will populate. This time this textbox should be a auto-complete . this is not happend in my page. this page has lot of onblur event's also.
1
1763
by: thubba2000 | last post by:
We have a web application developed using IBuySpy. In older versions, Autocomplete on all web forms works. In our latest version, it stopped working on all clients. I have gone through all the groups and tried a bunch of things. Two main areas I keep seeing are, 1. Browser Settings not set correctly. 2. Ability to turn off Autocomplete for a control and a form.
2
3130
by: dneupane | last post by:
Hi all How can I get combobox autocomplete working with button click event, my application cannot use keyboard, so I have soft keypad. Any help would be greatly appreciated. Regards Niju
1
3854
by: wkerplunk | last post by:
Below is what I have build with several different languages. It works great but I need help, I am stuck. When you click on an item in the dropdown autocomplete div it does a mousedown function and send the item number to the xmlHttp and works awesome. Now I need to add an apply button next to it. so they can type in the complete number then hit apply and it does the same function. I cant get it to work with the script I have. The image...
3
4749
by: John | last post by:
AC2007 I changed my combo's row source and then the autocomplete stopped working. The combo is two columns, bound to the first. First column is primary key (ID). Second column is a concatenation of two fields (Descrip & UserID). When I start typing letters of an existing description (Descrip), the combo does not autocomplete. If I select a choice from the combo, it
10
4047
by: kym | last post by:
I am having problems using the ajax autocomplete. I actually think it may be an Oracle problem not autocomplete problem because I can get the autocomplete working without searching the database for like values. Here is my code: Imports System Imports System.IO Imports System.Web Imports System.Web.Services Imports System.Web.Services.Protocols Imports System.Collections Imports System.Collections.Generic Imports System.Threading
5
3367
by: Pat | last post by:
Hi ASP Gurus, Please help me. Autocomplete works fine when the control does not have the focus when the page load. But when I put the focus on page load, then autocomplete does not work. I even tried javascript pageload code, but with no success. <script language ="javascript" type ="text/javascript" > function focusIt() { //alert('test'); var mytext =
0
9618
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10101
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9906
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8933
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6710
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2849
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.