Jump to content
  • Advertisement
Sign in to follow this  
yaroslavd

[.net] HTML in labels

This topic is 4885 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, guys. I can't figure out for the life of me how to use html in labels. Specifically, I want to use subscript in my label, but the <html> and text just gets displayed. Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
If you're referring to the System.Windows.Forms.Label, then I'm afraid you can't. If you just want decorated text, try using RTF or a LinkLabel.

Share this post


Link to post
Share on other sites
What I'm looking to do is use subscripted text. And RTF doesn't seem to be working, either. Maybe I'm just typing in the html wrong. I tried:

<html>uk<html>


Sorry, the forum automatically converts the instructions to how they r supposed to display k. So I'm guessing that part is right.

Share this post


Link to post
Share on other sites
Quote:
Original post by yaroslavd
What I'm looking to do is use subscripted text. And RTF doesn't seem to be working, either. Maybe I'm just typing in the html wrong. I tried:

<html>uk<html>


Sorry, the forum automatically converts the instructions to how they r supposed to display k. So I'm guessing that part is right.

An RTF reader won't parse or render HTML, so that's probably why you're not seeing results. RTF does have a "\sub" reserved word for subscripts, though. Here's a short RTF document that shows uk in Arial 10pt, produced with WordPad (my RTF's a little rusty):

{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fcharset0 Arial;}}
{\*\generator Msftedit 5.41.15.1507;}\viewkind4\uc1\pard\f0\fs20 u\sub k\nosupersub\fs24\par
}


HTH,

Share this post


Link to post
Share on other sites
Quote:
Original post by yaroslavd
Well, I copy-pasted your text into the Text property of RTF box and it still doesn't work. :(

The Text property is the non-literal (non-RTF) text. What you want is the Rtf property. To put it another way, ".Text is what you see, but .Rtf is what you get".

Share this post


Link to post
Share on other sites
Use the @ form of the string;

String s = @"some\substring";

of escape the backslashes:

String s = "some\\substring";

Share this post


Link to post
Share on other sites
Ah, of course. You have to forgive me, I haven't programmed in months. However, if anyone can help me out, I'd still love a control that would display what I want in the designer.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!