lapucca
asked on
Can a Listbox control be configure to several Columns and each column with its own heading?
If not, is Listview the only control suitable for this? Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I don't think so.
but you can add serveral columns from a table to list box (but it is a tricky way) ..
assume you have a table .Say, "TableName" with the following columns( ID, UserName, UserNo)
in your code establish a connection with the database, then load the data by using dataprovider to your dataset.
Now, To be Allowed to show several columns of that table, you need to add another column to "TableName" in the dataset, Say, "col" and this column is of type string and is a concatenation of the columns you want to show in the list box.
ID UserName UserNo col
==========================
"1" "lapucca" "12345" "1 lapucca 12345"
"2" "DrAske" "00000" "2 DrAske 00000"
To add a new column to "TableName" in the dataSet add this line to your code :
yourDataSet.Tables["TableN
Now, the column "col" is added to your table.
To fill the list box with data do this :
yourListBox.DataSource = yourDataSet.Tables["TableN
yourListBox.DisplayMember = "col";
And thats it ;o)
hope that helps,
regards,Ahmad;