Question Position a LinkLabel

reza_ha29

New member
Joined
Dec 5, 2008
Messages
2
Programming Experience
Beginner
Hi everybody
I have a problem that I am trying to solve but after a week I haven't solved it:(
I want to put a linklabel at the end of a line in a TextBox.
Consider I have printed "This is an example" in a textbox. Now I want to put a link label "See more" at the end of this sentence. In other words, I want to create this:
This is an example. see more...

The problem is that I can not find the position of the last character of a sentence.
I will be grateful if you answer my question.
 
Why not use a RichTextBox since it supports URL's, simply parse the "URL" part in the Url click event and to handle whatever it is they clicked if it's not an actual url.
 
Dear JuggaloBrotha,
Thanks for your answer
But may be I couldn't explain the problem correctly.
The problem is that I want to place a linklabel at the end of a sentence and the length of that sentence is not definite. consider these examples:
1) This a test. see more
2) I love programming by Visual Basic. See more

In both cases I want to place a linklabel at the end of the sentence and the length of sentence is not definite for me.
 
Hmm, it appears that I was wrong, the RichTextBox wouldn't work in this case, it's URL detection is only for URL's themselves so using a fake url specifying the clickable text wouldn't work. However the Webbrowser control can:
VB.NET:
Public Class Form1
    Private m_Loading As Boolean = True

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        WebBrowser1.DocumentText = "1) This a test. <a href=""http://www.TestSeeMore.com"">See more</a><br>2) I love programming by Visual Basic. <a href=""http://www.VBSeeMore.com"">See more</a>"
        m_Loading = False
    End Sub

    Private Sub WebBrowser1_Navigating(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserNavigatingEventArgs) Handles WebBrowser1.Navigating
        Select Case e.Url.OriginalString.ToLower.Replace("http://www.", String.Empty).Replace(".com/", String.Empty)
            Case "testseemore" : MessageBox.Show("Test See More")
            Case "vbseemore" : MessageBox.Show("VB See More")
        End Select
        e.Cancel = Not m_Loading
    End Sub
End Class
 
Back
Top