By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,665 Members | 1,513 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,665 IT Pros & Developers. It's quick & easy.

problem with Autocomplete and Leave focus event

P: n/a
I made a simple app to test Leave focus event and AutoComplete
functionality on the text box control. I added 2 text box controls on
the blank form. Then I added Leave focus event handlers for these text
boxes, set AutoCompleteMode property to SuggestAppend and
AutoCompleteSource property set to CustomSource.
AutoCompleteCustomSource property is changed in a Leave focus event
handlers for each text box, see code below. When I run the application
and changed focus with TAB key, focus still stood on the first text
box. Simply said, it is impossible to change focus with TAB key. Any
suggestions how to solve this problem?

public partial class Form1 : Form
{
AutoCompleteStringCollection textBox1AutoCompleteCollection =
new AutoCompleteStringCollection();
AutoCompleteStringCollection textBox2AutoCompleteCollection =
new AutoCompleteStringCollection();

public Form1()
{
InitializeComponent();
}

private void InitializeAutoComplete()
{
textBox1AutoCompleteCollection.Clear();
textBox2AutoCompleteCollection.Clear();

textBox1AutoCompleteCollection.Add("Sunday");
textBox1AutoCompleteCollection.Add("Monday");
textBox1AutoCompleteCollection.Add("Tuesday");
textBox1AutoCompleteCollection.Add("Wednesday");
textBox1AutoCompleteCollection.Add("Thursday");
textBox1AutoCompleteCollection.Add("Friday");
textBox1AutoCompleteCollection.Add("Saturday");

textBox2AutoCompleteCollection.Add("Peter");
textBox2AutoCompleteCollection.Add("John");
textBox2AutoCompleteCollection.Add("Martin");
textBox2AutoCompleteCollection.Add("George");

textBox1.AutoCompleteCustomSource =
textBox1AutoCompleteCollection;
textBox2.AutoCompleteCustomSource =
textBox2AutoCompleteCollection;
}

private void Form1_Load(object sender, EventArgs e)
{
InitializeAutoComplete();
}

private void textBox1_Leave(object sender, EventArgs e)
{
InitializeAutoComplete();
}

private void textBox2_Leave(object sender, EventArgs e)
{
InitializeAutoComplete();
}
}
Jan 11 '08 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.