ListBox.Items.Add question

mpdillon

Member
Joined
Feb 17, 2005
Messages
20
Location
Glen Mills, PA
Programming Experience
Beginner
I am adding items to a listbox. I would like the items to be aligned vertically in columns. To accomplish this in VB6, I would use a Courier New font and pad the items to achieve the proper spacing to give the visual affect of columnar data. I have tried the same thing in vb.net. However, the .Add method removes the padding.

I start with:



strLine = strDept.PadRight(30, " ") + "- " + strPos

I can view the item in debug and I see strline = “Dept Name padded to 30 spaces – Position”

However after lstDept.add(strline), the list box on the form displays:

“Dept Name – Position”.

The padding which was applied to the Dept Name is gone, except for the single space in front of the dash.

I am doing this on a Web Form but I am assuming the behavior is a VB behavior. That is why I posted here.

Can anyone offer an explanation.

Thanks
 

Schenz

Well-known member
Joined
Sep 11, 2004
Messages
181
Location
Cincinnati, OH
Programming Experience
5-10
I would actually guess that this is HTML behavior. I would actually use the non-breaking space and see what happens:

VB.NET:
[font=Times New Roman][size=3]strLine = strDept & " [/size][/font][font=Times New Roman][size=3] [/size][/font][font=Times New Roman][size=3] [/size][/font][font=Times New Roman][size=3] [/size][/font][font=Times New Roman][size=3] [/size][/font][font=Times New Roman][size=3] [/size][/font][font=Times New Roman][size=3] [/size][/font][font=Times New Roman][size=3] [/size][/font][font=Times New Roman][size=3] [/size][/font][font=Times New Roman][size=3] [/size][/font][font=Times New Roman][size=3] [/size][/font][font=Times New Roman][size=3] [/size][/font][font=Times New Roman][size=3] [/size][/font][font=Times New Roman][size=3] [/size][/font][font=Times New Roman][size=3] [/size][/font][font=Times New Roman][size=3] [/size][/font][font=Times New Roman][size=3] [/size][/font][font=Times New Roman][size=3] [/size][/font][font=Times New Roman][size=3] [/size][/font][font=Times New Roman][size=3] [/size][/font][font=Times New Roman][size=3] [/size][/font][font=Times New Roman][size=3] [/size][/font][font=Times New Roman][size=3] [/size][/font][font=Times New Roman][size=3] [/size][/font][font=Times New Roman][size=3] [/size][/font][font=Times New Roman][size=3] [/size][/font][font=Times New Roman][size=3] [/size][/font][font=Times New Roman][size=3] [/size][/font][font=Times New Roman][size=3] [/size][/font][font=Times New Roman][size=3] [/size][/font][font=Times New Roman][size=3]- " & strPos
[/size][/font]
 
Top Bottom