0
votes

I am developing a DLL which is loaded into a Tab page in a Enteprise application.

A ListBox control (single select) has an event on listBox_SelectedValueChanged where the use choosed between different "Display Styles" which when changes fires a sub-routine to reload a DataViewGrid control with different information. Code is below for this:

private void listBox_SelectedValueChanged(object sender, EventArgs e)
{
    MessageBox.Show("LBSVC Value:" + listBoxDisplayStyles.SelectedValue + " -- Index:" + listBoxDisplayStyles.SelectedIndex);
    if (listBoxDisplayStyles.SelectedValue != null)
        PatientChanged(true); // true = force a refresh           
}

Now inconsistently when finished interacting with DGV control (no editing, just scrolling and ToolTip triggering to show extended information on the cells) I move the mouse back over the listbox control and click a different line to. The new listbox line becomes current (selection bar appears), but the event does not seem to be triggered (ie the MessageBox does not appear and nothing happens.

1

1 Answers

0
votes

Why don't you try SelectedIndexChanged event instead. Therein you can still use listBox.SelectedValue to fetch current value and act accordingly.

BTW it looks like you're working with more than one ListBox here. The event handler uses the object name listBox whereas the event body uses listBoxDisplayStyles. That might have something to do with the problem you're facing. But first try SelectedIndexChanged and let us know.