Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

How do I read in data from a datareader into a multicolumn listbox. I have for example

 

While varReader.Read

me.listbox1.Items.Add(varReader.Item(0).ToString & vbtab & varReader.Item(1).ToString)

Loop

 

I cannot get the second item to go into the next column. How do I accomplish this? Any help given would be greatly appreciated.

Posted
You misunderstand the MultiColumn property of the ListBox class. It works similarly to WordWrap in a TextBox. There is still only one list of items in the ListBox. When the items fill the space vertically, the next item is displayed in the next column. It is done automatically and you have no control over it. If you alter the size of the ListBox then the list items will reflow so that a vertical scrollbar is not required. That is the sole purpose of MultiColumn, which you would know if you had read the appropriate help topic. Try adding several items to a MultiColumn ListBox in the designer and resize it and see what happens. If you want a genuinely multicolumn list, you need to use a DataGrid or a ListView. I believe I once saw a user-posted control that was derived from the ListBox at the Code Project. You might like to take a look there.

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...