Question How to bold text string when adding it to listbox?

vb_noob

Member
Joined
Mar 28, 2011
Messages
6
Programming Experience
Beginner
Hi there,

I'm adding text string into a list box together with data retrieved from text box, and I wanna bold that text but really don't have any idea how to do so.

E.g. listProducts.Items.Add("Product Name - " & textProdName.text)

I just wanna bold that first bit of text in the quotes.

Could anyone please tell me how to do so?

Thank you very much.

Regards,
vb_noobs
 
You can't Bold part of it in a label -- it's either all bold or none. What you can do is split up the text and use more than one label. Then change the font to Bold in one of them.
 
In a ListBox, you set the Font property and then all items use that Font. You can't even use multiple Fonts between items, never mind within items.

If you want to do something fancy then you will need to owner-draw the items. That means you take responsibility for using GDI+ to draw the items as you want, which is fiddly but allows much more freedom. Have a look online for any examples of using the DrawItem event of the ListBox, you can then adapt the principles to your needs. If you want to use two different Fonts then you will have to call DrawString twice.
 
I see. Well, nevermind then. I was wondering if there is any easy method.
Nevertheless, thanks for the replies.

Cheers and regards,
vb_noob
 
Back
Top