By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,567 Members | 1,554 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,567 IT Pros & Developers. It's quick & easy.

columns and headings in listboxes

P: n/a
Hello, would anybody be able to tell me how to set a listbox's headings
in code? as well as how to define which column of a listbox data should
go into. I have a listbox that should have 2 columns, each with a
heading, and im running a loop to populate the listbox with data from
sql server.

Nov 13 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Beacher wrote:
Hello, would anybody be able to tell me how to set a listbox's headings
in code? as well as how to define which column of a listbox data should
go into. I have a listbox that should have 2 columns, each with a
heading, and im running a loop to populate the listbox with data from
sql server.


The rowsource for a list box includes the headers if you set:

me.LstBoxName.ColumnHeads = True

The above will set the first two values in the data as the headers of
the row source. As you loop through your SQL data, you can before, or
afterward tack on headings to the string that comprises the rowsource.
Values need to be separated by semi-colons.

Make sure the listbox row sourrce type is value list, ie,

me.LstBoxName.RowSourceType = "Value List"

So once you've looped through your data and come up with strData:

Col 1 Header;Col 2 Header;Col 1 Data 1; Col 2 Data 1; Col 1 Data 2; Col
2 Data 2 etc, etc

then you go:

me.LstBoxName.rowsource = strData

--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me
Nov 13 '05 #2

P: n/a
Thanks alot, much appreciated :) Works great!

Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.