This way...
private void Form1_Load(object sender, EventArgs e)
{
var source = new AutoCompleteStringCollection();
datatable dt = getdatafromsql("select name from tbl");
for (i=0;i<dt.rows.count;i++)>
{
source.Add(dt.rows[i][0].tostring(););
}
var textBox = new TextBox
{
AutoCompleteCustomSource = source,
AutoCompleteMode =
AutoCompleteMode.SuggestAppend,
AutoCompleteSource =
AutoCompleteSource.CustomSource,
Location = new Point(20, 20),
Width = ClientRectangle.Width - 40,
Visible = true
};
Controls.Add(textBox);
}
Happy Coding!
:)