lothos12345 Posted July 11, 2005 Posted July 11, 2005 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. Quote
jmcilhinney Posted July 12, 2005 Posted July 12, 2005 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. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.