Probléme de textbox par rapport a autocompletion
Bonjour,
je cherches a recuperer des éléments dans une textbox d'autocompletion via une requete Linq mais je ne sais pas du tous comment m'y prendre.
Code de mon autocompletion :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
//Chaine permettant de ramener les éléments de ma requéte.
string[] suggestions = { };
private void t_numdeco_TextChanged(object sender, EventArgs e)
{
if (!textChanging)
{
textChanging = true;
string prefix = "";
string text = t_numdeco.Text;
bool changed = false;
if (lastText.Length < text.Length && text.EndsWith(" "))
{
prefix = text;
changed = true;
}
else if (lastText.Length < text.Length && lastText.EndsWith(" ") && text.Contains(" "))
{
prefix = text.Substring(0, text.LastIndexOf(' '));
changed = true;
}
if (changed)
{
autoComplete.ReleaseAutoComplete();
autoComplete = new CustomSource(suggestions.Where(t => !prefix.Split().Contains(t)).Select(t => prefix + t).ToArray());
autoComplete.Bind(t_numdeco);
}
textChanging = false;
} |
Requete SQL que je souhaiterais utiliser pour faire ma requete LINQ :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
connexion.Open();
lock (this)
using (var command = new SqlCommand("SELECT * FROM dbo.T_Projets", connexion))
{
SqlDataReader dr = command.ExecuteReader();
while (dr.Read())
{
collec.Add(dr["CodeProjet"].ToString());
}
dr.Close();
dr.Dispose();
}
connexion.Close(); |
Merci d'avance car je suis vraiment perdu :ccool: !