Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

StatusBar DoubleClick event

Status
Not open for further replies.

MadJock

Programmer
Joined
May 25, 2001
Messages
318
Location
GB

Hi,

I currently have a status bar in my windows form. The status bar has three panels. I would like to perform a task when the user double clicks on the third panel.

I've looked at the StatusBar_DoubleClick event but cannot tell how to determine within this which panel the click originated from (the sender is the statusbar itself and the SystemEventArgs are empty).

Any help would be greatly appreciated!

Thanks,

Graeme

"Just beacuse you're paranoid, don't mean they're not after you
 
Answer to my own question:

Trap the status bar's 'PanelClick' event and store which panel was clicked. Then when you trap the double click, you already know which panel the double click took place in.

Example:

Code:
public class MyForm : System.Windows.Forms.Form

  private int _clickedPanel;

  // ....

  private void myStatusBar_PanelClick(object sender, System.Windows.Forms.StatusBarPanelClickEventArgs e){
    _clickedPanel = sbBOSS.Panels.IndexOf(e.StatusBarPanel);
  }  

  private void myStatusBar_DoubleClick(object sender, System.EventArgs e){
    MessageBox.Show("You clicked panel " + _clickedPanel.ToString());
  }
}

"Just beacuse you're paranoid, don't mean they're not after you
 
interesting solution, I was going to suggest using the mouse pos to determine which panel the pointer was over. I like your solution better!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top