Page 1 of 2 12 LastLast
Results 1 to 15 of 22
  1. #1
    Cryptonic's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    United Provinces of Canada
    Posts
    1,313
    Reputation
    44
    Thanks
    190
    My Mood
    Bored

    Thumbs up Saving/Editing/Removing ComboBox Data

    I'm making a program to save information for what data I have one disc's I have burned.

    Basically, what I am doing is I title a disc and burn the pictures/videos on to the dvd, then I want to create a item in a combo box with that name and then I will have a text box show the names of the videos/pictures that I want on in the disc.

    The problem is, I need the items to save in the combo box so that when I restart the programs, the items will still be there. I also would like to have an option to edit the names in case if I decide to change it, and if I decide to remove an item because maybe the disc broke or I made a new one with a different name, I would like to remove that item from the combo box.

    A few ways to do this is using my.settings or using an XML file. My.settings never seems to save when I move my program or copy it to another location. So I would like to use a XML file, though I have never used an XML file nor do I know how to add and remove data from it. Anyone mind explaining how to do so?

    This is kinda the idea of the program, though I'm probably going to change some things around:


    I've found an example on CodeProject, https://www.codeprojec*****m/Articles/...ove-Create-XML

    I have figured out how to add items to xml and read it. The only thing is, when the program loads, it only adds the most recent item from the XML file to the combo box.

    So this is what I am using:
    Code:
    Dim read As String
            read = Read_XML_Value_("\DiscInfo\Disc.xml", "/Root/", "Name")
            discsel.Items.Add(read)
    It just reads the first item off of the Root and adds it. So maybe I would have to create my own items after the root, but then I would have to load every item after that, and I would have to save every one separately, so I'm out of ideas.. any help?
    Last edited by Cryptonic; 04-21-2013 at 11:35 AM.

  2. #2
    Biesi's Avatar
    Join Date
    Dec 2011
    Gender
    male
    Posts
    4,993
    Reputation
    374
    Thanks
    8,808
    My Mood
    Twisted
    You can also use .ini files to save info

    API: WritePrivateProfileString, GetPrivateProfileString

  3. #3
    Cryptonic's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    United Provinces of Canada
    Posts
    1,313
    Reputation
    44
    Thanks
    190
    My Mood
    Bored
    Quote Originally Posted by Biesi View Post
    You can also use .ini files to save info

    API: WritePrivateProfileString, GetPrivateProfileString
    Yea, but ini files are more for settings... XML's are more for data. But really confusing ._.

  4. #4
    DawgiiStylz's Avatar
    Join Date
    Aug 2009
    Gender
    male
    Location
    Dawg House
    Posts
    7,811
    Reputation
    219
    Thanks
    2,896
    My Mood
    Tired
    Simple.

    Read from the .xml file you're wanting to use. Also, save as a list where you would be able to read/write to; to later save the data back into the .xml file.
    To edit, just edit the item of the list via the index of the item.

  5. #5
    Cryptonic's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    United Provinces of Canada
    Posts
    1,313
    Reputation
    44
    Thanks
    190
    My Mood
    Bored
    Quote Originally Posted by DawgiiStylz View Post
    Simple.

    Read from the .xml file you're wanting to use. Also, save as a list where you would be able to read/write to; to later save the data back into the .xml file.
    To edit, just edit the item of the list via the index of the item.
    I have that idea down.. stated in op. I'm stuck on how to load multiple items from an xml.

  6. #6
    Biesi's Avatar
    Join Date
    Dec 2011
    Gender
    male
    Posts
    4,993
    Reputation
    374
    Thanks
    8,808
    My Mood
    Twisted
    Code:
    dim xdoc as xdocument = xdocument.load(path)
    
    For Each xel In xdoc.Elements()(0).Elements()
       '###
    Next
    Code:
    <whatever>
    	<item>item1</item>
    	<item>item2</item>
    	<item>item3</item>
    </whatever>
    Last edited by Biesi; 04-23-2013 at 07:25 AM.

  7. The Following User Says Thank You to Biesi For This Useful Post:

    Cryptonic (04-23-2013)

  8. #7
    Cryptonic's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    United Provinces of Canada
    Posts
    1,313
    Reputation
    44
    Thanks
    190
    My Mood
    Bored
    Quote Originally Posted by Biesi View Post
    Code:
    dim xdoc as xdocument = xdocument.load(path)
    
    For Each xel In xdoc.Elements()(0).Elements()
       '###
    Next
    Code:
    <whatever>
    	<item>item1</item>
    	<item>item2</item>
    	<item>item3</item>
    </whatever>
    This would work... but when the XML saves with the same item name, it replaces the original one..

    But, I'll try some things when I get home. Do you have a method for saving to XML's as well?

  9. #8
    Biesi's Avatar
    Join Date
    Dec 2011
    Gender
    male
    Posts
    4,993
    Reputation
    374
    Thanks
    8,808
    My Mood
    Twisted
    Quote Originally Posted by PepsiXHacker View Post
    Do you have a method for saving to XML's as well?
    Xml.XmlTextWriter

  10. #9
    Cryptonic's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    United Provinces of Canada
    Posts
    1,313
    Reputation
    44
    Thanks
    190
    My Mood
    Bored
    Quote Originally Posted by Biesi View Post


    Xml.XmlTextWriter
    Can you explain how to use this?

    Only thing I got so far is Xml.XmlTextWriter.Create("C:\test.xml") o_o

    This page wasn't too helpful - XmlTextWriter Class (System.Xml)

    I also tried another code

    Code:
    Dim writer As New XmlTextWriter(directory, Nothing)
                writer.WriteStartElement("items")
                writer.WriteElementString("name", TxtBox1.Text)
                writer.WriteEndElement()
                writer.Close()
    But that replaces the same item as well.

  11. #10
    Biesi's Avatar
    Join Date
    Dec 2011
    Gender
    male
    Posts
    4,993
    Reputation
    374
    Thanks
    8,808
    My Mood
    Twisted
    Quote Originally Posted by PepsiXHacker View Post
    Can you explain how to use this?
    Code:
    dim enc as new system.text.unicodeencoding
    dim xwriter as new xml.xmltextwriter(directory, enc)
    
    with xwriter
      .writestartdocument()
      .writestartelement("whatever") '<whatever>
      .writestartelement("item") '<item>
      .writevalue("item1") 'item1
      .writeendelement() '</item>
      .writestartelement("item") '<item>
      .writevalue("item2") 'item2
      .writeendelement() '</item>
      .writeendelement() '</whatever>
      .close()
    end with
    something like that

  12. The Following User Says Thank You to Biesi For This Useful Post:

    Cryptonic (04-24-2013)

  13. #11
    Cryptonic's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    United Provinces of Canada
    Posts
    1,313
    Reputation
    44
    Thanks
    190
    My Mood
    Bored
    Quote Originally Posted by Biesi View Post


    Code:
    dim enc as new system.text.unicodeencoding
    dim xwriter as new xml.xmltextwriter(directory, enc)
    
    with xwriter
      .writestartdocument()
      .writestartelement("whatever") '<whatever>
      .writestartelement("item") '<item>
      .writevalue("item1") 'item1
      .writeendelement() '</item>
      .writestartelement("item") '<item>
      .writevalue("item2") 'item2
      .writeendelement() '</item>
      .writeendelement() '</whatever>
      .close()
    end with
    something like that
    Wouldn't that do the same as the other code I'm using? I'm trying to have an unlimitied ammount of values that can be entered by a user into an XML file. Then that data can be read when the program starts and entered it into the comx (damnit bo bo, go away >:O. Should be combo box). The thing is, if every name is different, you have to load it all seperatly (unless there's a way to do that).

    Sorry if this is confusing, I'm trying to think this out while I'm at school

    Thanks for all of your help so far.
    Last edited by Cryptonic; 04-24-2013 at 09:54 AM.

  14. #12
    Jorndel's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    Norway
    Posts
    8,676
    Reputation
    905
    Thanks
    19,113
    My Mood
    Angelic
    Well, this won't be of much help and it's my first XML usage code.
    It append "items" and add them attributes:
     


    I'll see if I can make something for you in the mean time
    Last edited by Jorndel; 04-24-2013 at 10:53 AM.

     
    Contributor 01.27.2012 - N/A
    Donator 07-17-2012 - Current
    Editor/Manager 12-16-12 - N/A
    Minion 01-10-2013 - 07.17.13
    Former Staff 09-20-2012 - 01-10-2013 / 07-17-2013 - Current
    Cocksucker 20-04-2013 - N/A

  15. The Following User Says Thank You to Jorndel For This Useful Post:

    Cryptonic (04-24-2013)

  16. #13
    Cryptonic's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    United Provinces of Canada
    Posts
    1,313
    Reputation
    44
    Thanks
    190
    My Mood
    Bored
    Quote Originally Posted by Jorndel View Post
    Well, this won't be of much help and it's my first XML usage code.
    It append "items" and add them attributes:
     


    I'll see if I can make something for you in the mean time
    This is what it created with that code

  17. #14
    1UP's Avatar
    Join Date
    Jul 2008
    Gender
    male
    Posts
    4
    Reputation
    10
    Thanks
    1
    This was something I did for an application, I probably wrote alot more then was really needed but I couldn't seem to get saving and resaving an xml file to work properly any other way.

    Saving the file
    Code:
        Private Sub saveCleaningLocations(ByVal folderPath As String)
    
    
            Dim writestart As Boolean
    
    
            'If file doesnt exist then set write to true
    
            If IO.File.Exists("CleaningLocations.xml") Then
                Dim currentXMLDocument As New XmlDocument
                currentXMLDocument.Load("CleaningLocations.xml")
    
                Dim parentNode As XmlNode = currentXMLDocument.SelectSingleNode("Locations")
    
                Dim prodnode As XmlNode = currentXMLDocument.CreateNode(XmlNodeType.Element, "FolderPath", "")
    
                prodnode.InnerText = folderPath
                parentNode.AppendChild(prodnode)
                currentXMLDocument.Save("CleaningLocations.xml")
    
            Else
                writestart = True
                Dim xmlFile As IO.FileStream = New IO.FileStream("CleaningLocations.xml", IO.FileMode.Append)
                Dim xmlTextWriter As New XmlTextWriter(xmlFile, System.Text.Encoding.Default)
                With xmlTextWriter
                    .Formatting = Formatting.Indented
                    .Indentation = 3
                    .IndentChar = CChar(" ")
                    If writestart Then .WriteStartDocument()
    
                    .WriteStartElement("Locations")
                    .WriteElementString("FolderPath", folderPath)
                    .WriteFullEndElement()
                    .Close()
    
                End With
    
            End If
            databind()
        End Sub
    Reading in the file
    Code:
      Private Sub ReadCleaningLocations()
    
            If IO.File.Exists("CleaningLocations.xml") Then
                Dim documentClean As XmlReader = New XmlTextReader("CleaningLocations.xml")
                While (documentClean.Read())
                    Dim type = documentClean.NodeType
    
                    If type = XmlNodeType.Element Then
                        If documentClean.Name = "FolderPath" Then
                            CreateRows(documentClean.ReadInnerXml.ToString)
                        End If
                    End If
                End While
                documentClean.Close()
            End If
        End Sub
    This was a copy and paste right from my app so you may have to pick what you need out of it, but as it is, it's working code

  18. The Following User Says Thank You to 1UP For This Useful Post:

    Cryptonic (04-24-2013)

  19. #15
    Cryptonic's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    United Provinces of Canada
    Posts
    1,313
    Reputation
    44
    Thanks
    190
    My Mood
    Bored
    I have no idea how you're banned, but if you're not permanently banned, you used this for saving folder locations? And what did you insert the data to, a listbox?

Page 1 of 2 12 LastLast

Similar Threads

  1. how to use Gibs Save Edit
    By iampain13 in forum Borderlands 2 Hacks
    Replies: 2
    Last Post: 11-12-2012, 01:07 AM
  2. Threads about Packet Editing Removed?
    By domer in forum Staff Disputes
    Replies: 2
    Last Post: 09-20-2011, 09:42 AM
  3. [Help Request] Is it possible to edit(remove) the suit voice?
    By The-_-enD in forum Crysis 2 Help
    Replies: 2
    Last Post: 05-22-2011, 02:38 PM
  4. [SOLVED]Map Saving/Editing
    By icygrave in forum Call of Duty Modern Warfare 2 Help
    Replies: 3
    Last Post: 08-24-2010, 11:31 AM
  5. [Help] Save Items in Combobox[Solved]
    By FatCat00 in forum Visual Basic Programming
    Replies: 8
    Last Post: 04-13-2010, 04:01 AM