hello all,
i have a little logical issue that i have a textbox,when i enter a character in txtbox, keypress event fired first and after that same time textchanged event fired as well.After entering character,autocompletecustomsearch open and when i press down key from keyboad to select text from that customsource,textchanged event was fired first and after that other events fired.I only need that when i press down key,that textchanged event should not be fired.what u suggest.
How to control textbox events at same time.
Page 1 of 11 Replies - 293 Views - Last Post: 27 July 2011 - 04:10 AM
Replies To: How to control textbox events at same time.
#2
Re: How to control textbox events at same time.
Posted 27 July 2011 - 04:10 AM
Hi my friend you have to put a textbox above combobox and set this codes .
i try it and it's work 100%
i try it and it's work 100%
public partial class Form1 : Form
{
List<string> name = new List<string>();
int i = 0;
public Form1()
{
InitializeComponent();
name.Add("samer");
name.Add("sameer");
name.Add("somaia");
name.Add("amjad");
name.Add("ahmad");
name.Add("akram");
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
i = 0;
comboBox1.DroppedDown = false;
string partial_name = textBox1.Text;
comboBox1.Items.Clear();
foreach (string s in name)
{
if (s.StartsWith(partial_name))
comboBox1.Items.Add(s);
}
comboBox1.DroppedDown = true;
}
private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
switch (e.KeyCode)
{
case Keys.Down:
if (i < comboBox1.Items.Count)
{
i++;
comboBox1.SelectedIndex = i - 1;
}
break;
case Keys.Up:
if (i > 0)
{
i--;
comboBox1.SelectedIndex = i - 1;
}
break;
case Keys.Enter:
textBox1.Text = comboBox1.Text;
comboBox1.DroppedDown = false;
break;
case Keys.Escape:
comboBox1.DroppedDown = false;
break;
}
}
}
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote




|