Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

ok i have a listbox with a few rows of data. I am having the data be read as a string into a word document.

 

I want to be able to read the whole listbox as a string.

 

So far I have only been able to get it to read one line. This is the code i used for that... listbox1.SelectedItem. Is there anyway to have it use the whole thing and not just one selected item???

  • Leaders
Posted
You should be able to iterate through all the items (the Items property) using a For Each loop, and join them together into one long string, using whatever you like as a separator, though it will probably be a comma or a new line. How is the ListBox populated? I'm not sure if this would work with a databound ListBox.
[sIGPIC]e[/sIGPIC]
Posted
As marble_eater said. You should use the Items property in Web Application. But it would be best to use the SelectedItems property in a Windows Application. I believe it would work even if you're using a databound listbox because binding means filling the Items. So we should be able to access the Items of the ListBox.
Amir Syafrudin
Posted
Using SelectedItems would only enumerate selected items. Assuming you would like to enumerate all items, you should use the Items property.

 

Thx for the correction. I kinda miss the "using the whole thing" in the question. I'm not adding anything more to this thread. Although I was wondering why would Talk2Tom11 loads the data to a listbox when in the end the items will be concatenate as a whole string. :confused:

Amir Syafrudin

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...