473,387 Members | 3,781 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Diffrent fonts in one label

Hello

I'm using System.Windows.Forms.Label and I want to add some text, where
one or more words are bold or italic.

I tried it with html tags but does not work. Somewhere i did read it
should be done by html tags. I did it like this:
label1.Text="my <b>test</b> string";
In the output i can see the html tags.<

I hope someone can tell me how to do this.

Thanks

Roggey

Nov 17 '05 #1
2 8032
Hi,

You cannot do this.

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
<Ro****@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Hello

I'm using System.Windows.Forms.Label and I want to add some text, where
one or more words are bold or italic.

I tried it with html tags but does not work. Somewhere i did read it
should be done by html tags. I did it like this:
label1.Text="my <b>test</b> string";
In the output i can see the html tags.<

I hope someone can tell me how to do this.

Thanks

Roggey

Nov 17 '05 #2
<Ro****@gmail.com> wrote...
I'm using System.Windows.Forms.Label and I want to add some text, where
one or more words are bold or italic.
Not with the regular Label...
I tried it with html tags but does not work. Somewhere i did read it
should be done by html tags. I did it like this:
label1.Text="my <b>test</b> string";
In the output i can see the html tags.
You have possibly seen that mentioned for the Java JLabel...
I hope someone can tell me how to do this.


You can construct a Control of your own.

To give you a hint what you can do, here's a speedy hack, inheriting from a
RichTextBox:
class RTFLabel : System.Windows.Forms.RichTextBox
{
public RTFLabel()
{
// Note! This control can't take "Transparent" as BackColor,
// So you'll have to make something of this...

this.BackColor = System.Drawing.SystemColors.InactiveBorder;
this.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.ReadOnly = true;
}

public void Append(string text, Font f)
{
int length = text.Length;
int start = this.Text.Length;
this.AppendText(text);
this.Select(start, length);
this.SelectionFont = f;
this.Select(0,0);
}

public void Append(string text, FontStyle fs)
{
Font f = new Font(this.Font, fs);
this.Append(text, f);
}

public void AppendRegular(string text)
{
this.Append(text, FontStyle.Regular);
}
public void AppendBold(string text)
{
this.Append(text, FontStyle.Bold);
}
public void AppendItalic(string text)
{
this.Append(text, FontStyle.Italic);
}
public void AppendUnderline(string text)
{
this.Append(text, FontStyle.Underline);
}

public void AppendStrikeout(string text)
{
this.Append(text, FontStyle.Strikeout);
}
}
-------------

So, you can use this instead of the regular Label...

// Bjorn A
Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jack Charbonneau | last post by:
I have a bunch of custom fonts installed on my system. For instance if I look at the font drop-down in word pad I see about 90 fonts, but if I build an app using VS.Net, add a label, and try to...
3
by: Frank Reintgen | last post by:
Hallo! (Soory for my english ;-) ) I have create a style like this: a:link { text-decoration:none; font-weight:bold; color:red; } a:visited { text-decoration:none; font-weight:bold;...
5
by: Olli Krollmann | last post by:
hello folks, we have been developing several .NET-based windows forms applications during the last two years. there are two mysterious display problems that we have encountered so far but have...
3
by: Jim Kroger | last post by:
I am trying to use nice fonts for my nav menu. I downloaded and installed a very nice font. I opened photoshop and made nice labels with text to use for the images for the nav menu. I use...
7
by: Shyguy | last post by:
I have an option group with about 30 options. I would like to have the Option Labels get their text from a table. Is this possible, and if so how? Also, is it possible to embad a font into a...
2
by: Stuart Norris | last post by:
Dear Group, I have a question about the result from ‘graphics.MeasureString' when using a mono-spaced font. Firstly I assume that Courier New font is mono-spaced, ie each character takes up the...
2
by: Zyrthofar Blackcloak | last post by:
Hello everyone! I just wanted to know how I can create a font from bitmaps in memory (currently in an array), or from GDI+. I want to be able to use that font in a textbox, for example. I have...
2
by: Jeff Law | last post by:
I'm having considerable difficulty getting a LED/LCD style font to work in VB.Net (on a Button). The font that I want to use (a Corel-sourced one) will work in VB6, but not in VB.Net. It says...
1
by: krikaran adel | last post by:
Hi, First of all I found your tips very usfull, of course these tips becuas of all years working in access. really greet site. my Quation: is this away to change fonts in reports so the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.