Solution 1 is a good suggestion although it will not fix the problem with the text written backwards you need to move the text caret to the end of the line using some thing like combo.SelectionStart = combo.Text.Length; as shown below.
private void comboBox1_TextChanged(object sender, EventArgs e)
{
string[] Addresses = { "http://google.com/", "http://www.yahoo.com/" };
comboBox1.Items.Clear();
foreach (string a in Addresses)
if (a.Contains(combo.Text))
combo.Items.Add(a);
combo.DroppedDown = true;
combo.SelectionStart = combo.Text.Length;
}
Some code that might help you figure something out with selecting using keyboard:
List<int> matchingIndexes = new List<int>();
int index = 0;
bool selecting = false;
private void comboBox1_TextChanged(object sender, EventArgs e)
{
string[] Addresses = { "http://google.com/", "http://www.yahoo.com/" };
if (!selecting)
{
comboBox1.Items.Clear();
matchingIndexes.Clear();
foreach (string a in Addresses)
{
if (a.Contains(comboBox1.Text))
{
comboBox1.Items.Add(a);
matchingIndexes.Add(comboBox1.Items.IndexOf(a));
}
}
comboBox1.DroppedDown = true;
comboBox1.SelectionStart = comboBox1.Text.Length;
}
}
private void comboBox1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Down)
{
selecting = true;
if (index > matchingIndexes.Count - 1)
{
index = matchingIndexes.Count - 1;
}
else if (index < 0)
{
index = 0;
}
comboBox1.SelectedIndex = matchingIndexes[index++];
}
else if (e.KeyCode == Keys.Up)
{
selecting = true;
if (index < 0)
{
index = 0;
}
else if (index > matchingIndexes.Count - 1)
{
index = matchingIndexes.Count - 1;
}
comboBox1.SelectedIndex = matchingIndexes[index--];
}
}
private void comboBox1_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Down || e.KeyCode == Keys.Up)
{
selecting = false;
}
}