Results 1 to 12 of 12

Thread: [RESOLVED] How to make an html preview on using textbox or richtextbox

  1. #1

    Thread Starter
    Hyperactive Member shyguyjeff's Avatar
    Join Date
    Jul 2007
    Location
    City of Durian
    Posts
    289

    Resolved [RESOLVED] How to make an html preview on using textbox or richtextbox

    Hello everyone..I have a problem here regarding to html and html preview..I have 3 tabs and I want the first tab to be plain text..My Second tab will be the html codes wherein i can let the user paste define an html code there. While in the third tab i want it to preview the html...Could anyone help me how to some solution to it? Actually this is the format:





    Thanks in advance for the people who can help me.
    Last edited by shyguyjeff; May 19th, 2009 at 03:05 AM.

  2. #2
    PowerPoster keystone_paul's Avatar
    Join Date
    Nov 2008
    Location
    UK
    Posts
    3,327

    Re: How to make an html preview on using textbox or richtextbox

    If you are saying you actually want to view the HTML as it would appear in Internet Explorer on the third tab then use a webbrowser control for the HTML Preview tab.

    When the user changes tabs away from the HTML source tab, save the contents of the text box containing the source and then when the HTML preview tab is activated use the webbrowser.Navigate method to load it.
    Last edited by keystone_paul; Apr 18th, 2009 at 03:09 AM.

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

    Re: How to make an html preview on using textbox or richtextbox

    I don't really understand what the difference between the first and second tab is supposed to be. HTML code is just text, after all.

    Are you saying that you want syntax highlighting in that second tab?

    As for the third tab, you would just use a WebBrowser and assign your HTML code to its DocumentText property.
    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

  4. #4

    Thread Starter
    Hyperactive Member shyguyjeff's Avatar
    Join Date
    Jul 2007
    Location
    City of Durian
    Posts
    289

    Re: How to make an html preview on using textbox or richtextbox

    Thanks keystone_paul. I will try to look for that webbrowser control for html.


    Quote Originally Posted by jmcilhinney View Post
    I don't really understand what the difference between the first and second tab is supposed to be. HTML code is just text, after all.

    Are you saying that you want syntax highlighting in that second tab?

    As for the third tab, you would just use a WebBrowser and assign your HTML code to its DocumentText property.

    About for that jm, hmmmp..I think there is no need for that, maybe I will just remove that tab. What really I want is that a user will encode an html format then it can preview as what the browser will shows. Thank you jm for reminding me that. Have a nice day.

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

    Re: How to make an html preview on using textbox or richtextbox

    Quote Originally Posted by keystone_paul View Post
    When the user changes tabs away from the HTML source tab, save the contents of the text box containing the source and then when the HTML preview tab is activated use the webbrowser.Navigate method to load it.
    No need for saving and navigating. As I said, just assign the HTML code directly to the DocumentText property.
    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

  6. #6
    PowerPoster keystone_paul's Avatar
    Join Date
    Nov 2008
    Location
    UK
    Posts
    3,327

    Re: How to make an html preview on using textbox or richtextbox

    NB - jmcilhinney is right that you can load the text directly without having to save it to a file, however I guess you will want to save the file at some point anyway so its up to you which way to do it.

  7. #7

    Thread Starter
    Hyperactive Member shyguyjeff's Avatar
    Join Date
    Jul 2007
    Location
    City of Durian
    Posts
    289

    Re: How to make an html preview on using textbox or richtextbox

    Yeah...jm is exactly right..I am working with it right now but could you site some example jm on how to set the document directly to html? Thanks again jm and also to you paul..
    Last edited by shyguyjeff; Apr 18th, 2009 at 04:38 AM.

  8. #8
    Hyperactive Member
    Join Date
    Jan 2009
    Posts
    429

    Re: [RESOLVED] How to make an html preview on using textbox or richtextbox

    richtextbox1.text= "<html><h1>Hello</h1></html>" 'This is html file ( ur richtextbox where html codes are there..

    webbrowser1.documenttext = richtextbox1.text ' This is ur webbrowsers whose document text is assigned whatever u have in richtextbox1.text ...


    Hope this helps...

  9. #9
    PowerPoster keystone_paul's Avatar
    Join Date
    Nov 2008
    Location
    UK
    Posts
    3,327

    Re: [RESOLVED] How to make an html preview on using textbox or richtextbox

    Quote Originally Posted by yogesh12 View Post
    richtextbox1.text= "<html><h1>Hello</h1></html>" 'This is html file ( ur richtextbox where html codes are there..

    webbrowser1.documenttext = richtextbox1.text ' This is ur webbrowsers whose document text is assigned whatever u have in richtextbox1.text ...


    Hope this helps...
    Isn't that exactly what JMcilhinney said?

  10. #10
    Hyperactive Member
    Join Date
    Jan 2009
    Posts
    429

    Re: [RESOLVED] How to make an html preview on using textbox or richtextbox

    Quote Originally Posted by keystone_paul View Post
    Isn't that exactly what JMcilhinney said?
    yeah it is

  11. #11
    PowerPoster isnoend07's Avatar
    Join Date
    Feb 2007
    Posts
    3,237

    Re: [RESOLVED] How to make an html preview on using textbox or richtextbox

    some code i use for webbrowser
    Code:
    htmlEditor.document.execcommand "ForeColor", False, v
        htmlEditor.SetFocus
    
    htmlEditor.document.execcommand "Bold", False, Nothing      
        htmlEditor.SetFocus
    
    htmlEditor.document.execcommand "fontsize", False, cboSize.Text
        htmlEditor.SetFocus
    
    htmlEditor.document.execcommand "fontname", False, cboFont.Text
        htmlEditor.SetFocus
    
    
    htmlEditor.document.execcommand "underline", False, Nothing
        htmlEditor.SetFocus
    End Sub
    
    
    htmlEditor.document.execcommand "Italic", False, Nothing
        htmlEditor.SetFocus
    
    
    'Insert image from file
    htmlEditor.document.execcommand "InsertImage", "C:\Image234.jpg"
    
    'Open picture dialog
    htmlEditor.Document.execCommand "InsertImage", True
    Waiting for a full featured smart phone with out marrying a provider
    Go Android
    Go raiders

  12. #12

    Thread Starter
    Hyperactive Member shyguyjeff's Avatar
    Join Date
    Jul 2007
    Location
    City of Durian
    Posts
    289

    Re: [RESOLVED] How to make an html preview on using textbox or richtextbox

    Quote Originally Posted by keystone_paul View Post
    Isn't that exactly what JMcilhinney said?
    yes it is.. anyway I mark already this thread as resolved..Thank You everyone for the help.

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