/// <summary> /// 添加项目 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void m_mthComboBox_Additem(object sender, System.EventArgs e) { iCare.CustomForm.ctlComboBox cbo = ((MenuItem)sender).GetContextMenu().SourceControl as iCare.CustomForm.ctlComboBox; if (cbo == null) { return; } if (cbo.Text == "") { return; } clsComboBoxValue objValue = new clsComboBoxValue(); objValue.m_strDeptID = MDIParent.s_ObjDepartment.m_StrDeptID; objValue.m_strTypeID = m_strTemplateID; objValue.m_strItemID = cbo.Name; objValue.m_strItemContent = cbo.Text; long lngRef = new clsComboBoxDomainOld().m_lngAddItemToDB(objValue); if (lngRef < 1) { return; } cbo.Items.Insert(0, objValue.m_strItemContent); cbo.SelectedIndex = 0; }
/// <summary> /// 删除项目 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void m_mthComboBox_Deleteitem(object sender, System.EventArgs e) { iCare.CustomForm.ctlComboBox cbo = ((MenuItem)sender).GetContextMenu().SourceControl as iCare.CustomForm.ctlComboBox; if (cbo == null) { return; } if (cbo.Text == "" || cbo.SelectedItem == null) { return; } clsComboBoxValue objValue; objValue = new clsComboBoxValue(); objValue.m_strDeptID = MDIParent.s_ObjDepartment.m_StrDeptID; objValue.m_strTypeID = m_strTemplateID; objValue.m_strItemID = cbo.Name; objValue.m_strItemContent = cbo.SelectedItem.ToString(); long lngRef = new clsComboBoxDomainOld().m_lngDeleteItem(objValue); if (lngRef < 1) { return; } cbo.Items.Remove(cbo.SelectedItem); cbo.Update(); }
/// <summary> /// 加载控件信息 /// </summary> /// <param name="p_strXml"></param> private void m_mthLoadControl(string p_strXml) { XmlParserContext objXmlParser = new XmlParserContext(null, null, null, XmlSpace.None, System.Text.Encoding.Default); XmlTextReader objReader = new XmlTextReader(p_strXml, XmlNodeType.Element, objXmlParser); objReader.WhitespaceHandling = WhitespaceHandling.None; while (objReader.Read()) { switch (objReader.NodeType) { case XmlNodeType.Element: if (objReader.GetAttribute("TYPE") == null) { break; } infPublicFuntion infControl = new clsGenerateControlFactory().m_infGetControl(objReader.GetAttribute("TYPE").ToString()); infControl.ConfigMe(objReader); // ((Control)infControl).Name = m_strGetCtlName(p_ctlContainer,(Control)infControl); Form frm = this.m_pnlControl.FindForm(); if (frm is frmUserDefinedEditor) //设计界面才需要加控件事件 { ((frmUserDefinedEditor)frm).m_mthAddCtlEvent((Control)infControl); } else if (frm is frmCustomFormDesign) { ((frmCustomFormDesign)frm).m_mthAddCtlEvent((Control)infControl); } Control ctl = (Control)infControl; if (ctl != null) { switch (ctl.GetType().FullName) { case "iCare.CustomForm.ctlRichTextBox": ctl.BackColor = Color.White; ctl.ForeColor = Color.Black; break; case "iCare.CustomForm.ctlComboBox": //添加组合框项目事件 iCare.CustomForm.ctlComboBox cbo = ctl as iCare.CustomForm.ctlComboBox; cbo.DropDown += new System.EventHandler(m_mthComboBox_DropDown); cbo.evtAddItem += new System.EventHandler(m_mthComboBox_Additem); cbo.evtModifyItem += new System.EventHandler(m_mthComboBox_Modifyitem); cbo.evtDelItem += new System.EventHandler(m_mthComboBox_Deleteitem); break; default: ctl.BackColor = System.Drawing.SystemColors.Control; ctl.ForeColor = Color.Black; break; } m_pnlControl.Controls.Add(ctl); } break; } } //end whi }