Results 1 to 2 of 2

Thread: Save Checkbox values to XML

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2015

    Save Checkbox values to XML

    Hello, im new here. Still learning.
    I have a form on which there are around 15 checkbox. I wont to save the checkbox that is checked in an XML file or any other format that can be open with any specific application.
    I really need some help with this. Been stuck with it for a few days now

    The action is so:

    Upon click of a button1, it generates a file with the name of the checkbox that is checked.

  2. #2
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008

    Re: Save Checkbox values to XML

    Here is an example that saves the name and foreground color, add or subtract information as you see fit.

    Imports System.Xml
    Public Class Form1
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Dim Checked =
                    From T In Me.Controls.OfType(Of CheckBox)()
                    Where T.Checked Select T
            If Checked.Count > 0 Then
                Dim DataXml =
                    <%= From T In Checked Select
                            <Name><%= T.Name %></Name>
                            <ForeColor><%= T.ForeColor.Name %></ForeColor>
                        </CheckBox> %>
                Dim doc As New System.Xml.XmlDocument
                Dim xmldecl As XmlDeclaration
                xmldecl = doc.CreateXmlDeclaration("1.0", Nothing, Nothing)
                doc.InsertBefore(xmldecl, doc.DocumentElement)
            End If
        End Sub
    End Class

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Click Here to Expand Forum to Full Width