473,616 Members | 2,835 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Listbox item need spaces

hello All,

I have a simple question..I'm creating a tempString that
contains my values then i'm adding to a ListItemCollect ion
(). In my tempString i'm adding a spaces between each
values it works fine..when I add to a ListBox the HTML
doesn't render the spaces..Anyhelp is appreciated...

Tanks
Manan

code
-----
tempString = memLastName + Space(5) + memFirstName + Space
(5) + MemDob
tempItem = New ListItem()
tempItem.Text = tempString
tempItem.Value( ) = MemNbr
tempItemCollect ion.Add(tempIte m)

Next

ListBox1.DataSo urce = tempItemCollect ion
ListBox1.DataTe xtField = "Text"
ListBox1.DataVa lueField = "Value"
ListBox1.DataBi nd()
Nov 17 '05 #1
6 2866
Is there a question in this somewhere?
I guess it IS a simple question.
Here is the answer to the question " "
Nov 17 '05 #2
I had to override the RenderContents method of the listbox control, manually
putting out the <option> tags and data.

Before I wrote the Text of the ListItem out, I replaced all ' ' with
'&nbsp;' to get the desired columned effect.

bill
"Manan" <An******@hotma il.com> wrote in message
news:04******** *************** *****@phx.gbl.. .
hello All,

I have a simple question..I'm creating a tempString that
contains my values then i'm adding to a ListItemCollect ion
(). In my tempString i'm adding a spaces between each
values it works fine..when I add to a ListBox the HTML
doesn't render the spaces..Anyhelp is appreciated...

Tanks
Manan

code
-----
tempString = memLastName + Space(5) + memFirstName + Space
(5) + MemDob
tempItem = New ListItem()
tempItem.Text = tempString
tempItem.Value( ) = MemNbr
tempItemCollect ion.Add(tempIte m)

Next

ListBox1.DataSo urce = tempItemCollect ion
ListBox1.DataTe xtField = "Text"
ListBox1.DataVa lueField = "Value"
ListBox1.DataBi nd()

Nov 17 '05 #3
I don't know if this works but here is a google search solution. Be careful
of screen wrap.

http://groups.google.com/groups?hl=e...wnlist%2Bspace
"Manan" <An******@hotma il.com> wrote in message
news:04******** *************** *****@phx.gbl.. .
hello All,

I have a simple question..I'm creating a tempString that
contains my values then i'm adding to a ListItemCollect ion
(). In my tempString i'm adding a spaces between each
values it works fine..when I add to a ListBox the HTML
doesn't render the spaces..Anyhelp is appreciated...

Tanks
Manan

code
-----
tempString = memLastName + Space(5) + memFirstName + Space
(5) + MemDob
tempItem = New ListItem()
tempItem.Text = tempString
tempItem.Value( ) = MemNbr
tempItemCollect ion.Add(tempIte m)

Next

ListBox1.DataSo urce = tempItemCollect ion
ListBox1.DataTe xtField = "Text"
ListBox1.DataVa lueField = "Value"
ListBox1.DataBi nd()

Nov 17 '05 #4
Sorry wrong link.

http://groups.google.com/groups?hl=e...%3D10%26sa%3DN
"Manan" <An******@hotma il.com> wrote in message
news:04******** *************** *****@phx.gbl.. .
hello All,

I have a simple question..I'm creating a tempString that
contains my values then i'm adding to a ListItemCollect ion
(). In my tempString i'm adding a spaces between each
values it works fine..when I add to a ListBox the HTML
doesn't render the spaces..Anyhelp is appreciated...

Tanks
Manan

code
-----
tempString = memLastName + Space(5) + memFirstName + Space
(5) + MemDob
tempItem = New ListItem()
tempItem.Text = tempString
tempItem.Value( ) = MemNbr
tempItemCollect ion.Add(tempIte m)

Next

ListBox1.DataSo urce = tempItemCollect ion
ListBox1.DataTe xtField = "Text"
ListBox1.DataVa lueField = "Value"
ListBox1.DataBi nd()

Nov 17 '05 #5
Great Link!

I noticed that the code was using the string writer and I wondered why... so
I tried a little experiment and came up with this function:

Private Function Pad(ByVal numberOfSpaces As Int32) As String

Dim Spaces As String

For items As Int32 = 1 To numberOfSpaces

Spaces &= "&nbsp;"

Next

Return Server.HtmlDeco de(Spaces)

End Function

Now you can call it and add as many spaces to the front or back of a drop
down list item:

DropDownList1.I tems.Add(Pad(5) & "Indented")

Sincerely,
--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"vMike" <Mi************ @nospam.gewarre n.com.delete> wrote in message
news:bh******** **@ngspool-d02.news.aol.co m...
Sorry wrong link.

http://groups.google.com/groups?hl=e...%3D10%26sa%3DN

"Manan" <An******@hotma il.com> wrote in message
news:04******** *************** *****@phx.gbl.. .
hello All,

I have a simple question..I'm creating a tempString that
contains my values then i'm adding to a ListItemCollect ion
(). In my tempString i'm adding a spaces between each
values it works fine..when I add to a ListBox the HTML
doesn't render the spaces..Anyhelp is appreciated...

Tanks
Manan

code
-----
tempString = memLastName + Space(5) + memFirstName + Space
(5) + MemDob
tempItem = New ListItem()
tempItem.Text = tempString
tempItem.Value( ) = MemNbr
tempItemCollect ion.Add(tempIte m)

Next

ListBox1.DataSo urce = tempItemCollect ion
ListBox1.DataTe xtField = "Text"
ListBox1.DataVa lueField = "Value"
ListBox1.DataBi nd()


Nov 17 '05 #6
Hi Manan,

Have you tried Justin's code? If you have any questions, please post back.

--
Parker Zhang
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 17 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
3522
by: Lie | last post by:
Hi all, I have problem in getting selectedindex of multiple listbox selection in a datagrid. I have a listbox with multiple selection mode inside datagrid. In Edit mode, I need to get back all selected items of that listbox and display it. can anyone help? Thanks
8
2347
by: Steve Schroeder | last post by:
For some reason I cannot get the OnSelectedIndexChanged event to fire for a listbox I have on a page. I'm able to populate the listbox with data from a stored procedure, but cannot trigger the event. I do have EnableViewState = True for the listbox. I'm imagining (wanting) to populate the listbox named: lstNames by using the DataValueField from lstDepartments. It's quite apparent though that the event is not triggering as I can misname...
4
3973
by: Mike Parris | last post by:
I want to represent a list of items as a heirarchy by, indenting each item by a set amount depending on its level. For example level 1 = no spaces, level 1 = 2 spaces etc. If I try too use leading spaces or tabs to do this the control removes them. Is there a way to do this? Mike
1
1345
by: amber | last post by:
Hello, How can I capture data in a listbox that occurs BEFORE the selected item switches from one item to another? myListbox.validating triggers after the user has left the listbox. myListBox.selectedIndexChanged doesn't trigger until after the user has selected a new item.
2
2919
by: dachrist28 | last post by:
I am trying to populate a listbox with data that is pulled from a sql query. Here is my C# code behind the page: sqlConn1.Open(); SqlCommand sqlComm2 = new SqlCommand("SElECT replace((mc.MAINTENT.id + space(20-len(mc.maintent.id))+ left(mc.MAINTENT.aenm,50) + space(50-len(left(mc.maintent.aenm,50)))+mc.mtntype.id),' ','&nbsp') as Description, mc.maintent.mtnoi FROM mc.MAINTENT INNER JOIN mc.MTNTYPE ON mc.MAINTENT.mtctyp_oi =...
3
2542
by: rn5a | last post by:
I am not very sure whether I should have continued with my earlier thread or started a new thread whose subject matter was somewhat similar to the subject matter in this thread. Anyway after much deliberation, I decided to start a new thread. So here it is. Pardon me if I should have continued with my earlier thread instead of starting this new thread. A ListBox lists all the directories & files existing in a directory on the server....
4
4960
by: rn5a | last post by:
Can the items in a ListBox be sorted by the name of the items? The ListBox actually lists all directories & files existing in a directory on the server. Note that all the directories should be listed first followed by the files.
0
2676
by: LostInMd | last post by:
Hi All, I've got an owner drawn listBox where I draw and measure the items that I add to the listBox. For example, I have a listBox that can only display 10 characters on each horizontal line. The majority of my items contain much more than 10 characters and thus the reason for my use of owner drawn listBoxes - I do not want to use a horizontal scrollbar, instead I want the text of each item to wrap onto multiple lines. I do use a...
8
15416
by: jh | last post by:
I'd like to copy/paste into a listbox during runtime. I can do this for a textbox but can't figure out how to accomplish this for a listbox. Any help? Thanks.
0
8592
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8294
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8448
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6097
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5550
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4060
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4140
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1759
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1439
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.