Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Which Legend item is clicked?

If I put up a legend with my scatterplot and setup an OnClickLegend for the Click event in the legend, how do I know which Item it was that was clicked?
 

private void OnLegendClick(object sender, System.EventArgs e)

 

The System.EventArgs e is empty.

 
MS 7.1
VS 2003
C#
0 Kudos
Message 1 of 3
(3,283 Views)

You can do this by handling the Legend.MouseDown or Legend.MouseUp event and then using the Legend.GetItemAt method with the X/Y properties from the event arguments. If Legend.GetItemAt returns a non-null reference, that is the legend item that you clicked on. For example:

private void OnLegendMouseUp(object sender, MouseEventArgs e)
{
    LegendItem item = legend1.GetItemAt(e.X, e.Y);
    if (item != null)
        MessageBox.Show(item.Text);
}

- Elton

0 Kudos
Message 2 of 3
(3,268 Views)
That'll do it.  Thanks!
0 Kudos
Message 3 of 3
(3,265 Views)