943,150 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Marked Solved
  • Views: 868
  • VB.NET RSS
Feb 2nd, 2010
0

AutoComplete Dbgridview + textbox1.txt

Expand Post »
I Use visual Basic 8.0 and Mysql 5.0
I have one Table1:
Table1:
RecordID , Integer = primary key auto_increment NOT NULL
Articlenr , Integer
Articlename, Char(20)

Table1: has nine records:
RecordID, Articlenr ,Articlename
1 , 1100, Hamer Big Red
2 , 1110, Hamer Big Blue
3 , 1120, Hamer Big Yellow
4 , 1200, Hamer Medium Red
5 , 1210, Hamer Medium Blue
6 , 1210, Hamer Medium Yellow
7 , 1300, Hamer Small Red
8 , 1300, Hamer Small Blue
9 , 1300, Hamer Small Yellow

Use Datagridview en textbox1.txt

I would if I type in the item number in textbox1.txt in data grid view slow the correct article appears.

Example:
If i type number 11 in the textbox1.txt than datagridview shows:
1 , 1100, Hamer Big Red
2 , 1110, Hamer Big Blue
3 , 1120, Hamer Big Yellow

If i further expanding number with 10 result is than
1110 in the textbox1.txt than datagridview show only Hamer Big Red.
VB.NET Syntax (Toggle Plain Text)
  1.  
  2. Dim MyCommand1 As New MySql.Data.MySqlClient.MySqlCommand
  3. Dim Myadapter As New MySql.Data.MySqlClient.MySqlDataAdapter
  4. Dim MyBuilder As New MySql.Data.MySqlClient.MySqlCommandBuilder
  5. Dim MyDataTable As New DataTable
  6. MyCommand1.CommandText = "select * from Table1"
  7. MyCommand1.Connection = conn
  8. Myadapter.SelectCommand = MyCommand
  9. Myadapter.Fill(MyDatatable)
  10. DataGridView1.DataSource = MyDatatable

Thanks in advance,

Andre
Similar Threads
Reputation Points: 9
Solved Threads: 0
Junior Poster
dre-logics is offline Offline
102 posts
since Aug 2009
Feb 14th, 2010
0
Re: AutoComplete Dbgridview + textbox1.txt
I found the solution!! Here It is:
VB.NET Syntax (Toggle Plain Text)
  1. myAdapter1.Fill(MyDataset1, "table1")
  2. MyDataTable1 = MyDataset1.Tables("table1")
  3. DataGridView1.DataSource = MyDataTable1
  4. Private Sub TextBox1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
  5. Dim keywords As String = Val(TextBox1.Text)
  6. MyDataset1.Tables("table1").DefaultView.RowFilter = "articlenr like '*" & keywords & "*' "
  7. End Sub

But the articlenr must my a string field!!!
Last edited by dre-logics; Feb 14th, 2010 at 5:33 am.
Reputation Points: 9
Solved Threads: 0
Junior Poster
dre-logics is offline Offline
102 posts
since Aug 2009
Feb 14th, 2010
0
Re: AutoComplete Dbgridview + textbox1.txt
But one problem remains open!
How can I do the same with a numerical field {articlenr}.
So I want a Rowfilter => articlenr like TextBox1 (input)
I want to use LIKE operator!!!
Who knows the answer to this problem?
Reputation Points: 9
Solved Threads: 0
Junior Poster
dre-logics is offline Offline
102 posts
since Aug 2009
Feb 18th, 2010
0
Re: AutoComplete Dbgridview + textbox1.txt
I found the solution myself!!!
Is simple:

MyDataset1.Tables("table1").DefaultView.RowFilter = "Convert(articlenr , 'system.string') like '*" & keywords & "*' "
Reputation Points: 9
Solved Threads: 0
Junior Poster
dre-logics is offline Offline
102 posts
since Aug 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: TextChanged Event of TextBox
Next Thread in VB.NET Forum Timeline: How to load a .rdlc report file into the reportviewer in vb'08





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC