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

Aligning text to columns in a listbox when you don't know how many columns are needed

P: 22
all in vb2005
I have three arrays: one 2d array, two 1d arrays. I need to output them into a listbox and align them to columns, which I know how to do using string.format(blahblahblah). However, in this case the user is defining the necessary number of columns. Specifically, I have vb project that effectively gathers the scoring information for a soccer team and outputs it to a listbox. The gamedate array would be the first row, and the players' names would be the first column. However, the user determines the number of games played, and thus the number of dates, and thus the number of columns. My dad pointed out that I can just put all the dates into a single string using a do while loop, but that would be UGLY and wouldn't necessarily correspond with the alignment for the actual scoring information depending on how the user types the date. So my solution looks something like this:

dim intcount as integer = 0
dim strwhatever as string = ""
dim the rest of the stuff
do while intcount < intnumberofgames - 1

strwhatever = strwhatever & strdateofgame(intcount) & "(space)"
intcount = intcount + 1


This, however is unacceptable, because the user could type the date as 01/01/2000 or January 1, 2000, in which case the goals scored on that date won't necessarily align well because I don't know how much space the user will need. In short, how do I align listbox items to columns if I don't know how many columns I need?

ps - can't figure out bold facing. I want the header for the listbox to be bold, but the rest to be regular. How do I make single lines within the listbox bold? This is not nearly as important as the first and primary question.
May 13 '07 #1
Share this Question
Share on Google+
1 Reply

P: 22
May 14 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.