Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Adding controls to a windows from from XML

Adding controls to a windows from from XML

Scheduled Pinned Locked Moved C#
xmlperformancequestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    NewbieDude
    wrote on last edited by
    #1

    Hey howzit, i have a method below that loops through an XML document and adds textbox and checkbox controls to a panel based on the xml content. However the performance is not great all at...one can see all the controls are they are being displayed and it looks sloppy...is there not a better way of doing this? public void DeSerialize(XmlDocument xmlDoc, int currentPage) { XmlNode rootNode = xmlDoc.DocumentElement; foreach (XmlNode pageNode in rootNode.ChildNodes) { XmlAttributeCollection acPage; acPage = pageNode.Attributes; int pg = Convert.ToInt32(Convert.ToDouble(acPage.Item(0).InnerText)); if (pg==currentPage) { foreach (XmlNode fieldNode in pageNode.ChildNodes) { if (fieldNode["Type"].InnerText == "TextBox") { //create and add textbox to windows.forms.controls } else if (fieldNode["Type"].InnerText == "CheckBox") { //create and add checkbox to windows.forms.controls } } } } }

    J N 2 Replies Last reply
    0
    • N NewbieDude

      Hey howzit, i have a method below that loops through an XML document and adds textbox and checkbox controls to a panel based on the xml content. However the performance is not great all at...one can see all the controls are they are being displayed and it looks sloppy...is there not a better way of doing this? public void DeSerialize(XmlDocument xmlDoc, int currentPage) { XmlNode rootNode = xmlDoc.DocumentElement; foreach (XmlNode pageNode in rootNode.ChildNodes) { XmlAttributeCollection acPage; acPage = pageNode.Attributes; int pg = Convert.ToInt32(Convert.ToDouble(acPage.Item(0).InnerText)); if (pg==currentPage) { foreach (XmlNode fieldNode in pageNode.ChildNodes) { if (fieldNode["Type"].InnerText == "TextBox") { //create and add textbox to windows.forms.controls } else if (fieldNode["Type"].InnerText == "CheckBox") { //create and add checkbox to windows.forms.controls } } } } }

      J Offline
      J Offline
      J4amieC
      wrote on last edited by
      #2

      how about, hide the panel then add the controls then show the panel? Might stop the visual sloppiness! Also, seeing as you only need fast forward read access to your XML then you could use an XmlTextReader instead of the DOM implemntation (which allows read/write access and is unnecessary overhead if you want speed)

      1 Reply Last reply
      0
      • N NewbieDude

        Hey howzit, i have a method below that loops through an XML document and adds textbox and checkbox controls to a panel based on the xml content. However the performance is not great all at...one can see all the controls are they are being displayed and it looks sloppy...is there not a better way of doing this? public void DeSerialize(XmlDocument xmlDoc, int currentPage) { XmlNode rootNode = xmlDoc.DocumentElement; foreach (XmlNode pageNode in rootNode.ChildNodes) { XmlAttributeCollection acPage; acPage = pageNode.Attributes; int pg = Convert.ToInt32(Convert.ToDouble(acPage.Item(0).InnerText)); if (pg==currentPage) { foreach (XmlNode fieldNode in pageNode.ChildNodes) { if (fieldNode["Type"].InnerText == "TextBox") { //create and add textbox to windows.forms.controls } else if (fieldNode["Type"].InnerText == "CheckBox") { //create and add checkbox to windows.forms.controls } } } } }

        N Offline
        N Offline
        Nicholas Butler
        wrote on last edited by
        #3

        Hi You could try using SuspendLayout. ---------------------------- Be excellent to each other :) EasiReports[^] My free reporting component for WinForms.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups