I am doing a college project and need to display client status in form of coloured * by using an enum with flags...Now i know how the enum works but the problem is I need to show more than one * within the same field (lable or anything else) but each * with a different colour according to the creteria... Now i cant use label.forecolour cause that sets the whole lables' colour... Can anyone give me some advise?
phoenix_dwarf
0
Junior Poster in Training
Recommended Answers
Jump to PostIs it essental to use a single label? Labels don't have support for multicoloured text, so you can either create a custom user control or override the paint event to draw the *'s in different colours yourself.
It would be easier to have different labels that you simply set …
Jump to Post//attach event handler to Paint event in designer this.label1.Paint += new System.Windows.Forms.PaintEventHandler(this.label1_Paint); //then handle the event in code private void label1_Paint(object sender, PaintEventArgs e) { label1.Text = ""; label1.AutoSize = false; int width = (int)e.Graphics.MeasureString("*", f).Width; Font f = ((Label)sender).Font; label1.Width = (width * 3); Rectangle rect …
Jump to PostVery nice code Ryshad!
You only should swap line 9 and 10 otherwise f is used before it is defined.
All 11 Replies
Geekitygeek
480
Nearly a Posting Virtuoso
phoenix_dwarf
0
Junior Poster in Training
Geekitygeek
480
Nearly a Posting Virtuoso
ddanbe
commented:
Nice :)
+14
sknake
commented:
Glad to see another C# Solver on board!
+17
serkan sendur
commented:
yeah especially after serkan left
+11
chandru7
-1
Junior Poster in Training
ddanbe
2,724
Professional Procrastinator
Featured Poster
Geekitygeek
480
Nearly a Posting Virtuoso
phoenix_dwarf
0
Junior Poster in Training
Geekitygeek
480
Nearly a Posting Virtuoso
phoenix_dwarf
0
Junior Poster in Training
Geekitygeek
480
Nearly a Posting Virtuoso
Sairoj
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.