Results 1 to 9 of 9

Thread: Textbox and/or RTB Templates

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jul 2001
    Location
    Tucson, AZ
    Posts
    2,166

    Resolved Textbox and/or RTB Templates

    I've never seen anything on this.

    Anyone how you go about making a template for a textbox/RTB, such that when you load an unformatted file into the textbox, the text becomes formatted.

    My definition of "formatted" for this post means proper indenting in accordance with the template.

    Thanks
    David
    Last edited by dw85745; Jul 19th, 2005 at 09:16 PM.

  2. #2
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: Textbox and/or RTB Templates

    Quote Originally Posted by dw85745
    I've never seen anything on this.

    Anyone how you go about making a template for a textbox/RTB, such that when you load an unformatted file into the textbox, the text becomes formatted.

    My definition of "formatted" for this post means proper indenting in accordance with the template.

    Thanks
    David
    I think it's just as simple as loading a pre-saved RTF file.
    (Normal textbox doesn't support formatting!)
    VB Code:
    1. Dim TemplatesFolder As String
    2. TemplatesFolder = "C:\My Templates"
    3. RichTextBox1.LoadFile TemplatesFolder & "\MyFirstTemplate.rtf"

    Pradeep
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  3. #3
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Textbox and/or RTB Templates

    I have done formatting in Word, to create tables, and a picture box holder. I save it as a .RTF, and load it into my RTB control. In the file, I have [1],[2],[3]
    so that when it's loaded into the control, it's the template. Then I use .Select "[1]" to find the first placeholder, and then paste in the formatted field.

    I do this for 45 fields, and even paste in an image before I print it.

    You can do formatting for each field, and my receipt comes out correct every time.

    Then, I just print it out.

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Jul 2001
    Location
    Tucson, AZ
    Posts
    2,166

    Re: Textbox and/or RTB Templates

    Thanks for responses guys.

    Best way I can explain what I want to do is:

    Say I have an text file which groups my text under each XML tag.
    dglienna -- this would be the same as your [1] tag.


    If I indent my XML tags programically I also want the text to be
    programically indented under the XML tag. If the text for any
    specific XML tag wraps, I want the next line of text to also be indented at the same level as the XML tag.

    Sorry the below quote won't keep indenting but each tag is indented and
    the text line is indented under Tag3.


    VB Code:
    1. For example:
    2.  
    3. [Tag1]
    4.      [Tag2]
    5.      [/Tag2]
    6.      [Tag3]
    7.      <Text starts here and goes to end of textbox/RTB
    8.      <text starts her and goes to end of textbox/RTB
    9.      <text starts her and goes to end of text
    10.      [/Tag3]
    11. [/Tag1]

    Where the problem lies is programically getting the second, third, etc. text lines to indent. The only way I can see it is do a character count and compare this to the textbox width. Then force a Tab.
    Last edited by dw85745; Jul 18th, 2005 at 01:52 PM.

  5. #5
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Textbox and/or RTB Templates

    You could try to create the hanging indents in the Word document to see if the rtb control recognizes it.

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    Jul 2001
    Location
    Tucson, AZ
    Posts
    2,166

    Talking Re: Textbox and/or RTB Templates

    dglienna

    I know the RTB will handle indents (tags) as well as a Textbox.

    Where my hangup is ---- "whatever the meaning of is is " ----
    is that I need to do all indenting programmically (not manually) since I have
    a number of files, of which each may/may NOT have text that
    will wrap or some may wrap more lines than others.

    If this is doable in Word -- as you indicate -- a small example or snippet would be appreciated.

    David

  7. #7
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Textbox and/or RTB Templates

    I've set up field [1] with a hanging indent, one more than the others. When I replace it with a wrapped line, the line wrapped is also indented.

    I loaded it into Wordpad and used Find/Replace to make sure it worked the way that I expected it to.
    Attached Files Attached Files

  8. #8

    Thread Starter
    PowerPoster
    Join Date
    Jul 2001
    Location
    Tucson, AZ
    Posts
    2,166

    Re: Textbox and/or RTB Templates

    Thanks dglienna will take a look see.

    BTW: What's this rating business they started in the forum?
    Does rating ultimately result in money, a prize, or just personal
    satisfaction that one did a good job?

    Will be glad to rate you, when done this thread, if your desires?

    David

  9. #9

    Thread Starter
    PowerPoster
    Join Date
    Jul 2001
    Location
    Tucson, AZ
    Posts
    2,166

    Re: Textbox and/or RTB Templates

    dglienna

    Interesting idea to use MSWord with preset tags and then do a search/replace of tags to make and format a file.

    Let me know what I need to do to give you points and how many you would consider acceptable for your help on this?

    Thanks
    David

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