Results 1 to 7 of 7

Thread: [02/03] How do you Draw a Line in a Richtextbox

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2003
    Location
    California
    Posts
    79

    Question [02/03] How do you Draw a Line in a Richtextbox

    Hello Everyone,
    Can anyone Help me with this, How Do you Draw a Line in a Richtextbox. I don't even know where to Start Any Help would be great.

    Can be Fixed Width ie...5 or 6 inch or less.
    Also Different Line Widths. ie..1 point, 2 point, etc..

    Thanks,
    Robert
    Robert

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [02/03] How do you Draw a Line in a Richtextbox

    You draw a line on a RichTextBox the same way you do with any other control: using GDI+ in its Paint event handler. In the Paint event handler you would call the e.Graphics.DrawLine method. Presumably you want to draw this line in a location relative to some of the text. The RichTextBox class has numerous methods relating to text position, like GetPositionFromCharIndex. You can determine where to draw the line from such methods and then draw it with GDI+.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Nov 2003
    Location
    California
    Posts
    79

    Re: [02/03] How do you Draw a Line in a Richtextbox

    Could you help me out with some sample code. I'm New to VS2003.
    Do I have to Use Imports System.Drawing or ?

    Thanks,
    Robert
    Robert

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [02/03] How do you Draw a Line in a Richtextbox

    Actually, disregard what I said. I now recall that classes derived from TextBoxBase don't support GDI+ drawing.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Nov 2003
    Location
    California
    Posts
    79

    Re: [02/03] How do you Draw a Line in a Richtextbox

    So Is it Possible ? or is there a way to Create a Graphics ie...jpg or.bmp line and insert it into the Richtextbox ?

    Robert
    Robert

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [02/03] How do you Draw a Line in a Richtextbox

    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Nov 2003
    Location
    California
    Posts
    79

    Re: [02/03] How do you Draw a Line in a Richtextbox

    Thanks, I will
    Robert
    Robert

Posting Permissions

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



Click Here to Expand Forum to Full Width