torg Posted February 17, 2003 Posted February 17, 2003 (edited) The topic probably describes my problem, but as a matter of form: How do I show two columns in a Listbox. i.e I use: txtboxName, textboxBirth, textboxCity as input I want some thing like this: Name: Birth City John 12/12/1973 Paris Carl 05/11/2004 Hamburg Paul 01/02/1980 New York Per 02/02/1975 Oslo a code example would have been appreciated. Edited February 17, 2003 by torg Quote
*Gurus* Derek Stone Posted February 17, 2003 *Gurus* Posted February 17, 2003 Could you use a ListView instead? The ListView supports columns intuitively, while the ListBox does not. Take a look at it in your toolbox and let us know. Quote Posting Guidelines
torg Posted February 18, 2003 Author Posted February 18, 2003 That sounds like a good Idea, I`ll try that. meanwhile, I`ve come up with some code that I could have used instead: Public Class...... . . . Dim bill(2) As Budget Structure Budsjett Dim mystring1 As String Dim mystring2 As String Dim mystring3 As String End Structure , , , Public Sub ....... Bill(0).mystring1 = "Mystring" Bill(1).mystring2 = "Another String" Bill((2).mystring3 = "Yet another String" Dim formatstring As String = "{0,-15}{1,0}{2,15}" Listbox1.Items.Clear() Listbox1.Items.Add(String.Format(formatstring, Bill(0).mystring1 , Bill(1).mystring2 , Bill(2).mystring3)) the drawback is that I want to populate the listbox with several columns from one mdb table. Any idea about how to do that? This only gives me the data from column Expences ListBox1.DataSource = dsTenLast.Tables("dtTenLast") ListBox1.DisplayMember = "expencetype" Quote
*Experts* Volte Posted February 18, 2003 *Experts* Posted February 18, 2003 You could also look into using a DataGrid control; you can easily load in a DataSet and display the info, and it would probably do what you're asking about. I would suggest reading up on it. Quote
torg Posted February 19, 2003 Author Posted February 19, 2003 I`ve already tried that, and It works fine. But somehow, don`t ask why, I`ve decided to use Listbox., or atleast try to. Provided that it satisfies my needs 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.