Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Setting a value in DataTable fires SelectedIndexChanged event
- private void richTextBox1_TextChanged(object sender, EventArgs e)
- {
- if (listBox1.SelectedIndex != -1)
- {
- dataSet11.Notes.Rows[listBox1.SelectedIndex]["Text"] = richTextBox1.Text;
- //this line fires listBox1_SelectedIndexChanged event
- //with listBox1.SelectedIndex = -1
- //then it changes listBox1.SelectedIndex back to original value before complete execution, and calls the even again
- }
- }
- private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
- {
- }
- private TextBox_OntextChanged(object sender, EventArgs args)
- {
- this.supressEvents = true;
- //Do your stuff here
- this.supressEvents = false;
- }
- private void ListBox_OnSelectionChanged(object sender, EventArgs args)
- {
- if (this.supressEvents)
- {
- return;
- }
- //Do your stuff here
- }
- private void richTextBox1_TextChanged(object sender, EventArgs e)
- {
- listBox1.SelectedIndexChanged -= listBox1_SelectedIndexChanged;
- if (listBox1.SelectedIndex != -1)
- {
- dataSet11.Notes.Rows[listBox1.SelectedIndex]["Text"] = richTextBox1.Text;
- //this line fires listBox1_SelectedIndexChanged event
- //with listBox1.SelectedIndex = -1
- //then it changes listBox1.SelectedIndex back to original value before complete execution, and calls the even again
- }
- listBox1.SelectedIndexChanged += listBox1_SelectedIndexChanged;
- }
Add Comment
Please, Sign In to add comment