changing comboboc.selecteditem without triggering event

T

Torbjorn Stavas

Is there a way to change a selected item in a combobox, without
triggering the SelectedIndexChanged event?

I got listener on a few comboboxes, 'cause i want to save the changes
immediately to an instance of say... "foo". But when the user loads
another instance of "foo", i want to set the selecteditem in the
comboboxes to the appropriate values according to the loaded "foo",
without triggering the SelectedIndexChanged event.

I can solve this with the follow code

bool loadingOld = true;
private void comboBox1_SelectedIndexChanged(object sender,
System.EventArgs e)
{
if(!loadingOld)
{
foo.save()
}
}

, but i don't like the look of it.

So is ther anyone that knows if you can change selecteditem without
triggering the SelectedIndexChanged event?

//Kindest regards, Torbjorn
 
D

Daniel Moth

Another workaround is to remove the eventhandler, change the value and then
reattach it

Cheers
Daniel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top