![]() |
| | #1 |
| Registered User Join Date: Aug 2005
Posts: 16
| reading in files and populating the Combobox1 dropdown? in a nut shell i would like to say read a file like: ("example.txt") the array portion of this would be on the c# side of the file. the names or the right side of the = is the text file fields so to say. array1 =Texas array2 =Florida array3 =Southeast then, i would like to add those arrays to another variable like: OneArray<0>=array1 OneArray<1>=array2 OneArray<2>=array3 this should be easy enough but, im just starting out coding here. i have looked on msdn for collections, arraylist, and a few other commands but, nothing seems to be able to handle this.... eventually i would like to use this data in a combobox for end users to choose from. if this is possible then great! if not well then thanks for looking at it anyways. i have not found any code that would let me create this type of structure. I usually code in "pick" haha but, im sure if such a simple text based language can do it that c++ or c# should have some mannerism for this case. Last edited by fingerlickin; 08-11-2005 at 01:58 PM. |
| fingerlickin is offline | |
| | #2 |
| the hat of redundancy hat Join Date: Aug 2001 Location: Hannover, Germany
Posts: 2,769
| You can read lines from a file by using a stream reader as you already mentioned. You can split a line at a specific point by using the string.Split function. If you split your line at the = symbol you have a pair of words, a key ( array1 ) and a value ( Texas ). You can save a key/value pair with any IDictionary class. A Hashtable comes to mind here. You can later access the hashtable and get a value for the key you are looking for by using the index operator []: value = myhashtable["key"]; This would be a rather complex way of doing things. If you need values, you can add them by code or IDE. If you need them dynamic and from a file, just read the lines and add each line to the combobox.
__________________ hth -nv She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate." When in doubt, read the FAQ. Then ask a smart question. |
| nvoigt is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|