|
-
Oct 30th, 2007, 03:23 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] [2005] Application Properties Question
Currently I have an admin page that has 2 listboxes. One has a list of states that once one is selected supplies a list of counties for the other listbox. Both are set using the listboxes datasource property set to a stringcollection in the application settings.
I am also setting it up so that you can add item(s) to the state list. When an item is added to the state list it also adds a new countylist to the application settings (as a string collection).
The good news is that all this works fine. The problem I have is that when a user adds a new state, how do I reference the associated county list? I started with a case statement but once a user adds a value the case statement goes out the window. I tried to access it using
Code:
My.Settings.Properties.Item(st & "CountyList")
No good. Any ideas??
Thanks,
D
Platforms of choice: Visual Studio 2005/2008 Professional : Visual Studio 2010 Enterprise : PHP - Notepad++/WAMP
Please Rate If I helped you. 
Please remember to mark threads as closed if your issue has been resolved.
Reserved Words in Access | Connection Strings
-
Oct 30th, 2007, 03:36 PM
#2
Re: [2005] Application Properties Question
maybe im confused, when the user picks a state the other list fills with countries??? or is it the other way around?
Either way, how are you making you associations between the 2 collections now? IE, how do you determine what items to load in list2 when a user makes a selection in list1?
-
Oct 31st, 2007, 07:09 AM
#3
Thread Starter
Fanatic Member
Re: [2005] Application Properties Question
maybe im confused, when the user picks a state the other list fills with countries??? or is it the other way around?
LOL not countries, counties within each state (i.e. Lancaster County, Pennsylvania). To populate the box I have a string collection setup for each state so for example if the user picks "MD" as their state the county list box databinds to the string collection "MDCountyList". Which is stored in the application.settings. This may not be the "best" way, which is why I am here!!
Anyways, thanks for taking a look kleinma.
D
EDIT: My ultimate goal is to have a list of states that a user can edit and a list of counties for each state (kind of like a master detail kind of thing). I need to make it available to the entire application which is why I chose application settings. I may just have to use XML though huh?
Platforms of choice: Visual Studio 2005/2008 Professional : Visual Studio 2010 Enterprise : PHP - Notepad++/WAMP
Please Rate If I helped you. 
Please remember to mark threads as closed if your issue has been resolved.
Reserved Words in Access | Connection Strings
-
Oct 31st, 2007, 07:15 AM
#4
Re: [2005] Application Properties Question
-
Oct 31st, 2007, 07:21 AM
#5
Thread Starter
Fanatic Member
-
Oct 31st, 2007, 08:53 AM
#6
Re: [2005] Application Properties Question
why not use an XML file??? You can store it in the application settings, you can edit/append the XML file (its just text) by loading it up into an XMLDocument class, and you can store it back in your settings.
It would look something like this:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<states>
<state>
<name>Some State</name>
<county>Some County 1</county>
<county>Some County 2</county>
<county>Some County 3</county>
</state>
<state>
<name>Some Other State</name>
<county>Some Other County 1</county>
<county>Some Other County 2</county>
<county>Some Other County 3</county>
</state>
</states>
This code should get you started (added the above XML as a user setting string called MyXML)
Code:
imports system.xml 'at top
'CREATE XML DOCUMENT
Dim XMLDoc As New XmlDocument
'LOAD ITS CONTENTS FROM THE APPLICATION SETTINGS
XMLDoc.LoadXml(My.Settings.MyXML)
'STRING BUILDER IS JUST TO DISPLAY THE OUTPUT FOR THE EXAMPLE
Dim Output As New System.Text.StringBuilder
'FOR EACH STATE ELEMENT IN THE XML FILE, LOOP AND GET ITS NAME
For Each State As XmlElement In XMLDoc.DocumentElement.GetElementsByTagName("state")
Output.AppendLine("State: " & State.Item("name").InnerText)
Output.AppendLine()
Output.AppendLine("Counties:")
'THEN FOR EACH COUNTY ELEMENT INSIDE THE GIVEN STATE ELEMENT, GET THE COUNTY NAME
For Each County As XmlElement In State.GetElementsByTagName("county")
Output.AppendLine(County.InnerText)
Next
Output.AppendLine()
Output.AppendLine()
Next
'SHOW OUTPUT
MessageBox.Show(Output.ToString)
-
Oct 31st, 2007, 11:02 AM
#7
Thread Starter
Fanatic Member
Re: [2005] Application Properties Question
I am getting an error when I try to loadxml. It is saying "Data at the root level is invalid Line 1 Position 1. Here is the xml file:
Code:
<? xml version="1.0" encoding="utf-8" ?>
<states>
<state>
<name>DE</name>
<county>New Castle</county>
<county>Kent</county>
<county>Sussex</county>
</state>
<state>
<name>MD</name>
<county>Anne Arundel</county>
<county>Caroline</county>
<county>Cecil</county>
<county>Kent</county>
<county>Prince George's</county>
<county>Queen Anne's</county>
<county>Talbot</county>
</state>
<state>
<name>NJ</name>
<county>Atlantic</county>
<county>Bergen</county>
<county>Burlington</county>
<county>Camden</county>
<county>Cape May</county>
<county>Cumberland</county>
<county>Essex</county>
<county>Gloucester</county>
<county>Hudson</county>
<county>Hunterdon</county>
<county>Mercer</county>
<county>Middlesex</county>
<county>Monmouth</county>
<county>Morris</county>
<county>Ocean</county>
<county>Passaic</county>
<county>Salem</county>
<county>Somerset</county>
<county>Sussex</county>
<county>Union</county>
<county>Warren</county>
</state>
<state>
<name>PA</name>
<county>Montgomery</county>
<county>Bucks</county>
<county>Philadelphia</county>
<county>Snyder</county>
</state>
</states>
Here is the line of code that errors on me:
Code:
xmlStateCountyList.LoadXml(My.Settings.StateXMLLoc)
I am researching google as we speak. Hoping for a quick easy answer.
Platforms of choice: Visual Studio 2005/2008 Professional : Visual Studio 2010 Enterprise : PHP - Notepad++/WAMP
Please Rate If I helped you. 
Please remember to mark threads as closed if your issue has been resolved.
Reserved Words in Access | Connection Strings
-
Oct 31st, 2007, 11:33 AM
#8
Thread Starter
Fanatic Member
-
Oct 31st, 2007, 11:33 AM
#9
Re: [2005] Application Properties Question
this
<? xml version="1.0" encoding="utf-8" ?>
shoudl be this
<?xml version="1.0" encoding="utf-8" ?>
note no space after the ?
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
|