3 Replies - 346 Views - Last Post: 14 November 2017 - 06:29 AM Rate Topic: -----

#1 slyfuldragon  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 30
  • Joined: 07-November 10

Assistance on MouseOver LinkLabel to StatusStrip.Text

Posted 13 November 2017 - 10:48 AM

Good day all,

Been quite the while since I've found myself posting on here, but alas here I am...
Looking to see about some assistance on getting a MouseOver on LinkLabels (hyperlink site) to show up on StatusStrip.Text

Tried seemingly everything to me, but keep getting crashes with Mousehover (on/off events), etc...

The last thing I had was something like this (which I know just doesn't work) but maybe I'm simply overlooking a simple step after looking at this for some time--needing a fresh set of eyes.

    Private Sub LinkLabel_MouseEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.HtmlElementEventArgs) Handles LinkLabel1.MouseEnter
        ToolStripStatusLabel1.Text = e.ToElement.GetAttribute("href")
    End Sub



Any assistance is much appreciated, thank you.

Is This A Good Question/Topic? 0
  • +

Replies To: Assistance on MouseOver LinkLabel to StatusStrip.Text

#2 andrewsw  Icon User is offline

  • blow up my boots
  • member icon

Reputation: 6444
  • View blog
  • Posts: 26,064
  • Joined: 12-December 12

Re: Assistance on MouseOver LinkLabel to StatusStrip.Text

Posted 13 November 2017 - 02:26 PM

I don't know where ToElement and href are coming from...? Have you seen that somewhere?

I got it to display the link with:

    Private Sub LinkLabel1_MouseEnter(sender As Object, e As EventArgs) Handles LinkLabel1.MouseEnter
        Dim link = DirectCast(sender, LinkLabel)
        ToolStripStatusLabel1.Text = link.Links(0).LinkData.ToString

    End Sub

I don't know if there is a simpler way (haven't looked at WinForms for a while, nor recall using a LinkLabel).
Was This Post Helpful? 1
  • +
  • -

#3 slyfuldragon  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 30
  • Joined: 07-November 10

Re: Assistance on MouseOver LinkLabel to StatusStrip.Text

Posted 14 November 2017 - 06:06 AM

View Postandrewsw, on 13 November 2017 - 04:26 PM, said:

I don't know where ToElement and href are coming from...? Have you seen that somewhere?

I got it to display the link with:

    Private Sub LinkLabel1_MouseEnter(sender As Object, e As EventArgs) Handles LinkLabel1.MouseEnter
        Dim link = DirectCast(sender, LinkLabel)
        ToolStripStatusLabel1.Text = link.Links(0).LinkData.ToString

    End Sub

I don't know if there is a simpler way (haven't looked at WinForms for a while, nor recall using a LinkLabel).



Looks like that give me a, "An unhandled exception of type 'System.NullReferenceException' occurred in" error under the line of code for
 
           ToolStripStatusLabel1.Text = link.Links(0).LinkData.ToString


I did end up seeing that somewhere some time ago, but can't remember where.

So essentially what I have is several Linklabels that shoots you over to your default browser and opens up an instance of your router GUI but could like to display the hyperlink address in the ToolStripStatusLabel1

Private Sub LinkLabel1_LinkClicked(sender As Object, e As LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
        Dim webAddress As String = "https://##.##.##.##/"
        Process.Start(webAddress)
    End Sub

Private Sub LinkLabel2_LinkClicked...

Private Sub LinkLabel3_LinkClicked...

Private Sub LinkLabel1_MouseEnter(sender As Object, e As EventArgs) Handles LinkLabel1.MouseEnter
        Dim link = DirectCast(sender, LinkLabel)
        ToolStripStatusLabel1.Text = link.Links(0).LinkData.ToString

    End Sub


Could be an easier way to do this, but maybe I'm just having a brainfart (so to speak), anything else you happened to add that I might be missing which worked for you? Appreciate your assistance thus far!

This post has been edited by slyfuldragon: 14 November 2017 - 06:07 AM

Was This Post Helpful? 0
  • +
  • -

#4 andrewsw  Icon User is offline

  • blow up my boots
  • member icon

Reputation: 6444
  • View blog
  • Posts: 26,064
  • Joined: 12-December 12

Re: Assistance on MouseOver LinkLabel to StatusStrip.Text

Posted 14 November 2017 - 06:29 AM

LinkLabels have a Links collection and LinkData property that should be populated, to my understanding. At the moment it looks like you are just manually assigning/inventing a string (webAddress) for each label that is clicked. These webAddresses are local to the click events and won't be available in MouseOver.

To emphasise, the way you have it set up at the moment, you could equally well be using standard Labels rather than LinkLabels.

Please investigate the particular properties and behaviours of LinkLabels. Visit MSDN for documentation.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1