List Box

G

Guest

Hi Guys,

I need to append space in front of Directory names inside listbox based on
the folder level inside directory.

If i do
lBoxLocation.Items.Add(new ListItem(" "+
dirInfo.Name,dirInfo(i).FullName))

it adds in front of value. If i put white space, it dont appear at all.

Can someone tell me or guide me to an example which shows how to work with
this?

Thanks

Manny
 
K

Karl Seguin

Try running your string through an HtmlDecode:

dim spaces as string = DecodedSpaces(2)
lBoxLocation.Items.Add(spaces + dirInfo.Name,dirInfo(i).FullName)


public shared function DecodedSpaces(numberOfSpaces as integer) as string
dim spaces as string = ""
for i as integer = 0 to numberofSpaces - 1
spaces &= " "
next
return HttpUtility.HtmlDecode(spaces)
end function

Karl
 
D

Derek Harmon

Manny Chohan said:
I need to append space in front of Directory names inside listbox based on : :
it adds in front of value. If i put white space, it dont appear at all.

Manny,

Whitespace will be normalized by the browser, so no matter how many consecutive
spaces you send they'll appear as only one on the user's screen.

What you need to do is prepend non-breaking spaces,  , which the browser
won't force normalization of, e.g.,

lBoxLocation.Items.Add(new ListItem("    " + _
dirInfo.Name,dirInfo(i).FullName))

Each   will take up one space when seen in the browser by the user.


Derek Harmon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,792
Messages
2,569,639
Members
45,353
Latest member
RogerDoger

Latest Threads

Top