dcsimg
Results 1 to 5 of 5

Thread: Format rich textbox in design

  1. #1

    Thread Starter
    Frenzied Member schoemr's Avatar
    Join Date
    Apr 2016
    Location
    South Africa
    Posts
    1,073

    Format rich textbox in design

    Hi, I can find many examples of how to format a rich textbox - but that is when the app is running.. Then I can format and save richtextox. I want to do this in design. Meaning of the app runs it is already there.

    I want to have a RichTextBox1 where I say: "For more help please click here"

    the word "here" must be clickable and must be blue like a hyperlink and when you click on it it must open default email (Outlook) and insert the email address e.g. michelle@gmail.com

    Does someone know how to do this please?
    Don't miss the whole point of the dance...

    https://www.youtube.com/watch?v=qHnIJeE3LAI

  2. #2
    Frenzied Member ChrisE's Avatar
    Join Date
    Jun 2017
    Location
    Frankfurt
    Posts
    1,986

    Re: Format rich textbox in design

    try this

    Code:
    Public Class Form4
        Inherits System.Windows.Forms.Form
    
    
        Private Sub Form4_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            With RichTextBox1
    
                .Text = "use Hyperlinks form email " & vbCrLf & vbCrLf & _
                  "Contact the Admin: mailto://michelle@gmail.com" & vbCrLf & _
                  "or http://www.vbForums.com"
    
    
                'detect URL's autom.
                .DetectUrls = True
            End With
        End Sub
    
        Private Sub RichTextBox1_LinkClicked(ByVal sender As Object, _
        ByVal e As System.Windows.Forms.LinkClickedEventArgs) _
        Handles RichTextBox1.LinkClicked
    
            System.Diagnostics.Process.Start(e.LinkText)
        End Sub
    
    End Class
    Last edited by ChrisE; Aug 7th, 2019 at 06:20 AM.
    to hunt a species to extinction is not logical !
    since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.

  3. #3

    Thread Starter
    Frenzied Member schoemr's Avatar
    Join Date
    Apr 2016
    Location
    South Africa
    Posts
    1,073

    Re: Format rich textbox in design

    Quote Originally Posted by ChrisE View Post
    try this

    Code:
    Public Class Form4
        Inherits System.Windows.Forms.Form
    
    
        Private Sub Form4_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            With RichTextBox1
    
                .Text = "use Hyperlinks form email " & vbCrLf & vbCrLf & _
                  "Contact the Admin: mailto://michelle@gmail.com" & vbCrLf & _
                  "or http://www.vbForums.com"
    
    
                'detect URL's autom.
                .DetectUrls = True
            End With
        End Sub
    
        Private Sub RichTextBox1_LinkClicked(ByVal sender As Object, _
        ByVal e As System.Windows.Forms.LinkClickedEventArgs) _
        Handles RichTextBox1.LinkClicked
    
            System.Diagnostics.Process.Start(e.LinkText)
        End Sub
    
    End Class
    Thank you very much Chris
    Don't miss the whole point of the dance...

    https://www.youtube.com/watch?v=qHnIJeE3LAI

  4. #4
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    102,724

    Re: Format rich textbox in design

    Quote Originally Posted by ChrisE View Post
    try this

    Code:
    Public Class Form4
        Inherits System.Windows.Forms.Form
    
    
        Private Sub Form4_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            With RichTextBox1
    
                .Text = "use Hyperlinks form email " & vbCrLf & vbCrLf & _
                  "Contact the Admin: mailto://michelle@gmail.com" & vbCrLf & _
                  "or http://www.vbForums.com"
    
    
                'detect URL's autom.
                .DetectUrls = True
            End With
        End Sub
    
        Private Sub RichTextBox1_LinkClicked(ByVal sender As Object, _
        ByVal e As System.Windows.Forms.LinkClickedEventArgs) _
        Handles RichTextBox1.LinkClicked
    
            System.Diagnostics.Process.Start(e.LinkText)
        End Sub
    
    End Class
    Just FYI, VB has supported multiline String literals for a while now. Some people don't like using them but my preference is to do so. You can do so like this:
    Code:
                .Text = "use Hyperlinks form email
    
    Contact the Admin: mailto://michelle@gmail.com
    or http://www.vbForums.com"
    I find that more readable but some people are not big fans of the need to push everything to the left of the code window to avoid lots of leading whitespace.

  5. #5
    Frenzied Member ChrisE's Avatar
    Join Date
    Jun 2017
    Location
    Frankfurt
    Posts
    1,986

    Re: Format rich textbox in design

    Quote Originally Posted by jmcilhinney View Post
    Just FYI, VB has supported multiline String literals for a while now. Some people don't like using them but my preference is to do so. You can do so like this:
    Code:
                .Text = "use Hyperlinks form email
    
    Contact the Admin: mailto://michelle@gmail.com
    or http://www.vbForums.com"
    I find that more readable but some people are not big fans of the need to push everything to the left of the code window to avoid lots of leading whitespace.
    thanks for the Info,
    I use vb2008, time to Upgrade
    I tried VS 2017 and don't like it , I think I will go for VS2010 since it should be more than enough for my
    needs
    to hunt a species to extinction is not logical !
    since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width