how to apply different formatting to parts of group box text ie. part of the text has 2 be in black and the other half in grey?
Plz help

Dani AI

Generated

A short addendum tying the replies together and showing practical options for different environments.

asked about multi-colored group box text. sought clarification, and and correctly pointed out that some UI toolkits expose only a single caption/text property. For web pages (HTML/CSS) you can split the caption into runs and style each run. Example using a semantic fieldset/legend:

<fieldset>
  <legend><span class="black">Part A</span> <span class="grey">Part B</span></legend>
  <!-- content -->
</fieldset>
legend { padding: 0 .5em; }
legend .black { color: #000; }
legend .grey  { color: #777; }

Notes and gotchas: legend layout and exact rendering vary between browsers, so test in your target browsers. Keep the semantic legend for accessibility rather than faking the caption with non-semantic elements; see the element spec and browser guidance on legend for details (MDN: legend, WHATWG: legend). If you need pixel-perfect placement or must support older engines, a visually positioned element over the fieldset border is a common fallback.

If this is a desktop UI instead of HTML: WPF makes this trivial because a GroupBox header can contain a TextBlock with inline Runs (each Run can have its own Foreground). WinForms GroupBox.Text does not support multiple colors; on that platform the usual approaches are owner-drawing the caption or positioning separate label controls where the caption would be (the workaround mentioned earlier). For WPF reference see the GroupBox/TextBlock docs (WPF GroupBox).

Recommended Answers

All 5 Replies

You mean, the title of the Group Box has to have two different font colors?

I'm not entirely sure that's possible.

This is not possible. You can color the text, but only int one color.
If you want to have two or more color, there is a work-around.
Create labels, and put them in the position of the groupBox text. Color the what eve you want.

Revise property of group box you will get everything about it. You can not make half with different colours.

Hi smith.smith8086
Please can you elaborate a bit on your reply...didnt get that completely.

He is telling you the same as I did. Not possible. But you can take a look into my last post, where I gave you a work around solotion.

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.