1

if i have these lines in my TextBox_Validating the tabstop on the TextBox will fired twice:

((TextBox)sender).AutoCompleteCustomSource.AddRange(new string[]
{
    ((TextBox)sender).Text,
});

But if remove the lines above the Tabstop works fine and fired only once?

This is the whole function:

 private void TextBox_Validating(object sender, EventArgs e)
    {
        if (!((TextBox)sender).AutoCompleteCustomSource.Contains(((TextBox)sender).Text) && ((TextBox)sender).TextLength > 0)
        {
            ((TextBox)sender).AutoCompleteCustomSource.AddRange(new string[]
            {
               ((TextBox)sender).Text,
            });

            SaveHistoryTextBox(((TextBox)sender));
        }
    }

1 Answers1

0

Ok i found a workaround..

        private void TextBox_Validating(object sender, EventArgs e)
    {
        if (!((TextBox)sender).AutoCompleteCustomSource.Contains(((TextBox)sender).Text) && ((TextBox)sender).TextLength > 0)
        {
            ((TextBox)sender).AutoCompleteCustomSource.AddRange(new string[]
            {
               ((TextBox)sender).Text,
            });

            SaveHistoryTextBox(((TextBox)sender));

            Control p;
            p = ((TextBox)sender).Parent;
            p.SelectNextControl(ActiveControl, true, true, true, true);
        }
    }

With p.SelectNextControl i set manually the focus to the next control. So my tabstop is working.