Ich möchte eine Zeile von Text Link in Rich Text Box von vb.net setzen. Wie zum Beispiel: Ich möchte Sie kennenRichTextBox
Das Wort will, möchte ich ein Link-Wort setzen.
Kann ich das tun? Wenn kann, bitte hilf mir!
Danke, Sopolin
Ich möchte eine Zeile von Text Link in Rich Text Box von vb.net setzen. Wie zum Beispiel: Ich möchte Sie kennenRichTextBox
Das Wort will, möchte ich ein Link-Wort setzen.
Kann ich das tun? Wenn kann, bitte hilf mir!
Danke, Sopolin
Dies ist, wie ich es tun würde.
Dim linkLa As New LinkLabel
linkLa.LinkColor = Color.Red
Dim link As LinkLabel.Link = linkLa.Links.Add(0, 13, "http://www.stackoverflow.com")
linkLa.Text = "Stackoverflow"
AddHandler linkLa.LinkClicked, AddressOf Link_Clicked
richTextBox1.Controls.Add(linkLa)
Private Sub Link_Clicked(ByVal sender As Object, ByVal e As EventArgs)
MessageBox.Show("clicked")
End Sub
ich Ihre Antwort akzeptieren, aber ich möchte die Link-Adresse zeigen. – Sopolin
Sie könnten einfach nur richTextBox1.DetectUrls = True setzen und dann geben Sie einfach Ihre Adresse als Text ein. Oder ändern Sie linkLa.Text an die Adresse anstelle des Textes. –
Ich habe eine Antwort für Sie. Dadurch können Sie die Zieladresse des Links als Tooltip anzeigen. (kleine Pop-Up-Blase.) Ansonsten ist es ähnlich wie Stan Rs Antwort.
Anmerkung: Ich habe Kommentare vor jeder Zeile, so ist es einfacher zu folgen!
'define the text and link targets
Dim linktext As String = LinkTextbox.Text 'LinkTextbox is just the textbox where the user inputs the text of the link
Dim linktarget As String = LinkTargetTextbox.Text 'LinkTargetTextBox is just the textbox where the user inputs the target URL of the link
'Define the LinkLabel
Dim lnk As New LinkLabel
'if you want, you can set the different properties, like font or linkcolor, programmatically after defining the linklabel, for instance:
lnk.LinkColor = Color.Blue
'set tooltip
lnk.Tooltip = linktarget
'set the link target
Dim lk As LinkLabel.Link = lnk.Links.Add(0, 13, linktarget)
'set the link text
lnk.Text = linktext
'EventHandler
AddHandler lnk.LinkClicked, AddressOf LinkClicked
'Add the control to the richtextbox
RichTextBox1.Controls.Add(lnk)
'This is the Subroutine that the label will run when clicked (Make sure to put your "End Sub" before this, because it's not part of the button's subroutine)
Private Sub LinkClicked(ByVal sender As Object, ByVal e As EventArgs)
'send link to the browser
Process.Start(linktarget)
End Sub
gibt es so viele freie Redakteure gibt es prüfen nur eine von diesen fckeditor Google es – Nagu