public void AddControl(Control ctrl) { this.Visible = false; string XPath, sValue; XmlNode nodeControl; switch (ctrl.GetType().ToString().Replace("ToolsDocument.", "")) { case "ucCheckBox": ucCheckBox ucChb = (ucCheckBox)ctrl; XPath = ucChb._XPath; nodeControl = xmlDoc.SelectSingleNode(XPath); sValue = GetData(nodeControl); ucChb._Checked = strToBool(sValue); break; case "ucComboBox": ucComboBox ucCbx = (ucComboBox)ctrl; XPath = ucCbx._XPath; nodeControl = xmlDoc.SelectSingleNode(XPath); sValue = GetData(nodeControl); ucCbx._SelectedValue = sValue; break; case "ucDateTimePicker": ucDateTimePicker ucDtp = (ucDateTimePicker)ctrl; XPath = ucDtp._XPath; nodeControl = xmlDoc.SelectSingleNode(XPath); sValue = GetData(nodeControl); strToDate(sValue, ucDtp); break; case "ucRichTextBox": ucRichTextBox ucRtb = (ucRichTextBox)ctrl; XPath = ucRtb._XPath; nodeControl = xmlDoc.SelectSingleNode(XPath); sValue = GetData(nodeControl); ucRtb._Value = sValue; break; case "ucTextBox": ucTextBox ucTbx = (ucTextBox)ctrl; XPath = ucTbx._XPath; nodeControl = xmlDoc.SelectSingleNode(XPath); sValue = GetData(nodeControl); ucTbx._Value = sValue; break; case "ucPopup": ucPopup ucPP = (ucPopup)ctrl; XPath = ucPP._XPath; nodeControl = xmlDoc.SelectSingleNode(XPath); sValue = GetData(nodeControl); ucPP.Tag = sValue; ucPP._Text = nodeControl.InnerText; ucPopup ucSub = ucPP.GetSubPopup(); if (ucSub != null) { ucSub._RepleaceID = sValue; } break; case "ucDataGridView": ucDataGridView ucDGB = (ucDataGridView)ctrl; XPath = ucDGB._XPath; ucDGB.CreateDataSource(xmlDoc.SelectSingleNode(XPath)); break; case "ucRadioButton": ucRadioButton ucRB = (ucRadioButton)ctrl; XPath = ucRB._XPath; nodeControl = xmlDoc.SelectSingleNode(XPath); sValue = GetData(nodeControl); ucRB._Value = sValue; break; case "ucPictureImage": ucPictureImage ucPI = (ucPictureImage)ctrl; XPath = ucPI._XPath; nodeControl = xmlDoc.SelectSingleNode(XPath); sValue = nodeControl.InnerText; ucPI._imgBinary = sValue; break; case "ucNumericUpDown": ucNumericUpDown ucNUD = (ucNumericUpDown)ctrl; XPath = ucNUD._XPath; nodeControl = xmlDoc.SelectSingleNode(XPath); sValue = GetData(nodeControl); ucNUD._Value = strToDecimal(sValue); break; case "ucDoubleTextBox": ucDoubleTextBox ucDTB = (ucDoubleTextBox)ctrl; XPath = ucDTB._XPath; nodeControl = xmlDoc.SelectSingleNode(XPath); sValue = GetData(nodeControl); ucDTB._Value = sValue; break; } DocControl.AddControls(ctrl); }