I'm going nuts here...

Trying to find a control that will display nicely formatted text (preferably HTML) dynamically on a Windows form. Does anyone know or have experience with such a beast I have searched all over the Net and found lots of "browser" controls, but I don't want a Web browser - I just want to display nicely formatted text on a Windows form!!

Like this:

Dim sbText as New StringBuilder()
With sbText
   .Append("<p><b>This is a bold statement!</b></p>")
   .Append("<p>This is a not-so-bold statement.</p>")
End With
Me.SomeCoolLabelControl.Text = sbText.toString()

Any help here would be GREATLY appreciated!


Answer this question

I'm going nuts here...

  • Gary zhuo

    Thanks for the reply, but that's way overkill for my needs. I don't want to build an HTML editor, I just want an HTML label control.
  • Miskky

    I guess I could do that - if I could figure out all those crazy RTF codes...and then maybe pass the html string through some kind of an HTML to RTF converter...

    Am I the only one that wants/needs this kind of a control

    I can't stand looking at and creating "standard" Windows forms applications. What does MS use to create apps like Microsoft Money How do they create their "search results" task pane - that has to be created on the fly, right Why can't MS make that kind of technology easily available in thier Windows development tools

    grrr...


  • Harshal Kherde

    "of course the code is in C#, but it is your chance to graduate from VB to a real language :)"

    Oh brother! (...or sister...or whatever) ...give me a break.

    I've been programming since 1986, and I use the best language for the job. C# isn't more "real" than any other programming language I've ever used.

  • emp

    Thanks for the reply.

    I tried that one - it didn't seem to work very well, at least for me. In addition, there is no documentation. The page states it supports "semi-compatible" HTML tags, but I couldn't figure out what tags it supports and what it doesn't. I couldn't get a response from the "company" that developed it, so I dropped it like a hot potato.

  • BenoitFranc

    No, I don't think that's the main problem in my case. What mixed formatting are you talking about And how easy is it to format a label control with bold headings, line breaks, various font styles, etc.

    Unless you know about another label control that I don't know about, in which case Please Enlighten Me!

  • JimScudder

    Like I said in my original post, I don't want a web browser - I want a nicely formatted label control, which supports some basic formatting like Bold, Italics, various font sizes, line breaks, etc., etc.

    I'm not sure a webbrowser control would work, anyway. Doesn't that require you to have an HTML page to load The last time I checked you couldn't stream a string of HTML into it, like I showed in my original example.

    Also, the webbrowser control is ActiveX, which introduces unwanted dependencies into the project. If I wanted to build an HTML browser/editor, I might use something like the webbrowser control. That's not what I want to do, however.




  • Frank Boyne

    Thanks for the reply. I'm aware of that control, and I would definitely love to use it in our project. Unfortunately, our company won't even let us touch VS2005 until it goes out of beta and is a "real, shipping product" for at least six months or so. By that time, we will be nine months into a 12-15 month project.

    I did come across a control from a company called SyncFusion that has a Web browser control called HTMLUI. It allows me to set the text property of the control like in your example. However, they want about 500 bucks for it, and I don't know if I can justify that price for fancy labels.

    Thanks,

    Charles

  • mbkh_84

    try this---it's free---very nicely done---

    http://www.itwriting.com/htmleditor/index.php

    it will be using mshtml though---another 8 meg lib---maybe you don't care---anyway---you can download the source w/demo app

  • Luis Mack

    Why not use the WebBrowser control. It is for exacty what you want to do. If you didnt notice it also does editing of html.
    you can use MSHTML with WebBrowser here is a link:
    http://www.codeproject.com/csharp/webbrowser.asp

    of course the code is in C#, but it is your chance to graduate from VB to a real language :)

    HTH
    Regards

  • JoePD

    This may not be exactly what you're looking for, but I was in the same situation.  I wanted dynamic text that could be formatted as HTML to display in a label or textbox.  Unfortunately, as many of you already know, Visual Studio currently doesn't have an "HTML Textbox."  The only way I could feasibly get around this is to embed a Flash ActiveX component into my form, load a flash movie, and set a textbox within that flash movie dynamically with my text.  It's rather simple if you have Macromedia Flash MX(2004 with stylesheet support preferred) handy.  IMHO, much better than embedding a Web Browser object.

    Take care,

    Ronald

  • Mareen Philip.

    You can use the RichTextBox control with ReadOnly set to true. It supports RTF but you can do simple formatting in code by selecting some portion of the text using the Select() method and then changing its attributes using the SelectionFont, SelectionColor, etc properties.

    It's a bit clumsy. It would've been great if it supported HTML.

  • mladjoboy

    Hi Charles,

    I know that you have said a few times so far that you don't want to use a web browser, but I wanted to bring your attention to the web browser WinForms control that will be added to VS 2005.  It is incredibly easy to do exactly what you want to do using this control, and other than the fact that the underlying control is ActiveX like you mentioned, there is no reason you wouldn't want to use it.  Here's why:

    The code example that you gave at the beginning works with the web browser.
    Just drag a web browser onto the form, and change the line:


    Me.SomeCoolLabelControl.Text = sbText.toString()
     

    to


    Me.webBrowser1.DocumentText = sbText.toString()
     

    That's it, and it will be able to display any sort of html formatting you would want it to.

    Also if you don't want it to act in any way like a web browser, and more like a label, you can set AllowWebBrowserDrop, ScrollBarsEnabled, and WebBrowserShortcutsEnabled to false in the designer.  Now you have a "label" that can parse html and format the text correctly.

    I hope this helps.

    Scott Morrison
    Windows Forms PM
    Microsoft Corp.


  • Muty

    Heres a free label control that can display text formated using basic HTML.  Is this what you're looking for

    http://www.compona.com/WikiEngine/WikiPageViewer.ascx ID=44

    -Lee

  • HaidongJi

    Well, the main problem in your case is mixed formatting - you want part of the text to be in a different format than the rest. It's easy enough to format a label control otherwise.

    I do agree that it would be very useful to have the ability to use simple HTML to format the text, like that in Java Swing controls.

  • I'm going nuts here...