|
-
May 30th, 2002, 05:13 PM
#1
Thread Starter
Registered User
Need Control Array For This, Vb.net
I am loading a form which has Eight comboBoxes, named ComboStation1, ComboStation2, ComboStation3, etc. In each combobox I have to add 118 City names. Since Vb.net doesn't support control arrays, and there is no event for add_handler to handle such a task, is this the only way to program that....
VB Code:
Private Sub Combostation1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
comboSTATION1.Items.Add("Akron, OH"))
comboSTATION1.Items.Add("Albany, NY")
End Sub
and do that eight times. 8 * 118 = 944 lines of code to do such a simple task. IF ANYONE knows an easier way, i would greatly appreciate it.
thanks,
Jeff
-
May 30th, 2002, 05:35 PM
#2
Addicted Member
This might make it slightly easier for you.
Dim Cmbo as ComboBox = Ctype(sender,Combobox)
Cmbo.Items.Add (City)
It would be 1 * 118.
If you had a list you could read in, it would be much easier. Are you hand typing in all the names?
That which does not kill us, only makes us stronger. 
-
May 30th, 2002, 06:43 PM
#3
Thread Starter
Registered User
that isn't working, could you explain that further....
thanks
-
May 30th, 2002, 06:48 PM
#4
Addicted Member
you can create a single function that takes a combo box as a parameter. Then what ever combobox you pass can be loaded.
That which does not kill us, only makes us stronger. 
-
May 30th, 2002, 06:51 PM
#5
Thread Starter
Registered User
hey, thanks, i got it now... that is great..
jeff
-
May 30th, 2002, 06:55 PM
#6
Addicted Member
That may get ya down to 1* 118 anyway. Are you hardcoding the names in?
That which does not kill us, only makes us stronger. 
-
May 30th, 2002, 10:41 PM
#7
Junior Member
I don,t know all the facts of what your doing,but maybe creating text files migt be an idea.100 something values seems like a
lot to throw in a combbox..You could
create a module to write a file and a module to read one and
make changes if necessary,but I dont have a clue about the
application youre writing.I,ll just go back to my beer.
All The Best
-
May 30th, 2002, 11:20 PM
#8
Addicted Member
I agree. I think it would be better in the long run to have the variables in a text file, Excel Spreadsheet, or Database. You could make changes to them without having to recomplie or change any code. You may also find a use for them within another application.
That which does not kill us, only makes us stronger. 
-
May 30th, 2002, 11:49 PM
#9
Junior Member
control arrays
What was interesting was the idea of using
parameters with the combobox.That would be a
way to do all that control arrays can do.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|