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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Statusbar - How to retrieve the clicked panel name

Status
Not open for further replies.

jamesrhaynes

Programmer
Nov 1, 2003
19
0
0
US
I can determine which panel of a status bar was clicked by the index with the following code.

Private Sub StatusBar1_PanelClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.StatusBarPanelClickEventArgs) Handles StatusBar1.PanelClick
Dim stbPanel As StatusBarPanel
Dim intIndex As Integer
Try
stbPanel = e.StatusBarPanel
intIndex = StatusBar1.Panels.IndexOf(stbPanel)
Select Case intIndex
Case 0
Case 1
Case 2
End Select
Catch ex As Exception
'
End Try
End Sub

This is not reliable as the order can be changed quite easily. Other collections (e.g. toolbar) allow the retrieval of the item name or even provide a tag that can be used to identify. The status bar seems to have no means of identifying which panel was clicked. I could retrieve the panel text but that isn't a constant.

The command stbPanel.tostring gives just a generic string for any status bar panel with no indication of which panel it was. Isn't that strange!

My panels all have "Names" in design mode, how can I determine which Name was clicked so that the current order of layout is unimportant??
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top