Hey Guys! ,
Im having a bit of a problem here. I need to add a certain string in this case (') infront of every item in my listbox.

So lets say items are :
item1
item2
item3
item4

After i execute a code i want it to be
item1'
item2'
item3'
item4'

It would be highly appreciated if someone could help me out here!. Thanks alot

Recommended Answers

All 3 Replies

Just hardcoded the data with single quotes

lstView.Items.Add("CSharp'");
        lstView.Items.Add("Vb'");

Or
U can get data from backend and using the loop jus concate the backend data with "'" and add into listbox.

Hey when i do that it doesnt work. All it does is that it adds to items ( csharp' and vb')

thanks

If your listbox already contains items then this should work:

For i As Integer = 0 To lstBox.Items.Count - 1
   lstBox.Items(i) = lstBox.Items(i) & "'"
Next

Or if you need to add ' while adding items then this is the way to go:

lstBox.Items.Add(<some source> & "'")
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.