L
L
l2p2014-03-02 13:33:51
C++ / C#
l2p, 2014-03-02 13:33:51

How to make an AutoComplete form in C#?

I have t.Text - 3 letters that are entered.
DataTable dt = GetMusic(запрос);- so I have an interaction with the base.
I need to make a query that will select all names (name - column) from the table that include t.Text and convert them to string[]. Already tried a lot of things. Please help me!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey, 2014-03-02
Protko @Fesor

lmgtfy.com/?q=c%23+AutoComplete use LIKE
to query the database .

A
Alexander S, 2014-03-03
@FirstX

If you understand the condition correctly, then you can try something like this (the first thing that came to mind)

string query = String.Format("Select name From myTable Where name LIKE '{0}%'", t.Text);
DataTable dt = GetMusic(query);
var names = new string[dt.Rows.Count];

for (int index = 0; index < dt.Rows.Count; index++)
                names[index] = dt.Rows[index][0].ToString();

Instead of "myTable" the name of your table is of course

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question