예제 #1
0
 /// <summary>
 /// 复制控件时发生
 /// </summary>
 /// <param name="copycontrol">待添加的控件</param>
 void EditMainToolEventReferences_MainParsetControlRFrmEditControlListEvent(Control copycontrol, string controltype)
 {
     #region 控件信息类
     EditTemplateAddControlArgs addcontrol = new EditTemplateAddControlArgs();
     addcontrol.TAB_INDEX   = copycontrol.TabIndex.ToString();
     addcontrol.ITEM_CNAME  = copycontrol.Tag.ToString();
     addcontrol.ITEM_ENAME  = copycontrol.Name;
     addcontrol.ITEM_WIDTH  = copycontrol.Width;
     addcontrol.ITEM_HEIGHT = copycontrol.Height;
     addcontrol.POS_X       = copycontrol.Location.X;
     addcontrol.POS_Y       = copycontrol.Location.Y;
     if (copycontrol.GetType().ToString() == "System.Windows.Forms.RichTextBox")
     {
         addcontrol.MULTILINE = (copycontrol as RichTextBox).Multiline == true ? "是" : "否";
         addcontrol.WORD_WRAP = (copycontrol as RichTextBox).WordWrap == true ? "是" : "否";
         addcontrol.ITEM_TYPE = "RichTextBox";
     }
     else if (copycontrol.GetType().ToString() == "System.Windows.Forms.TextBox")
     {
         addcontrol.MULTILINE = (copycontrol as TextBox).Multiline == true ? "是" : "否";
         addcontrol.WORD_WRAP = (copycontrol as TextBox).WordWrap == true ? "是" : "否";
         addcontrol.ITEM_TYPE = "TextBoxText";
     }
     else if (copycontrol.GetType().ToString() == "System.Windows.Forms.PictureBox")
     {
         addcontrol.MULTILINE = (copycontrol as TextBox).Multiline == true ? "是" : "否";
         addcontrol.WORD_WRAP = (copycontrol as TextBox).WordWrap == true ? "是" : "否";
         addcontrol.ITEM_TYPE = "PictureBox";
     }
     #endregion
     EditEventReferences_EditAddControlEvent(addcontrol);
 }
예제 #2
0
 /// <summary>
 /// 添加控件
 /// <param name="location">控件初始坐标</param>
 /// </summary>
 private void AddControl(Point location)
 {
     try
     {
         //添加控件
         TextBox AddTextBox = new TextBox();
         AddTextBox.BorderStyle      = BorderStyle.FixedSingle;
         AddTextBox.TabIndex         = 1;
         AddTextBox.Width            = 200;
         AddTextBox.Location         = location;
         AddTextBox.Name             = "重命名" + DateTime.Now.ToString(); //防止名称重复;//英文名称
         AddTextBox.Tag              = "重命名" + DateTime.Now.ToString(); //防止名称重复;//中文名称
         AddTextBox.ContextMenuStrip = CMS_CustomMenu;                  //设置控件的快捷菜单
         AddTextBox.MouseDown       += new MouseEventHandler(CustomControl_MouseDown);
         AddTextBox.MouseMove       += new MouseEventHandler(CustomControl_MouseMove);
         AddTextBox.MouseUp         += new MouseEventHandler(CustomControl_MouseUp);
         AddTextBox.Move            += new EventHandler(CustomControl_Move);
         P_bgimg.Controls.Add(AddTextBox);
         //封装控件信息
         EditTemplateAddControlArgs addcontrolarge = new EditTemplateAddControlArgs();
         addcontrolarge.ITEM_CNAME  = AddTextBox.Name;
         addcontrolarge.ITEM_ENAME  = AddTextBox.Tag.ToString();
         addcontrolarge.ITEM_HEIGHT = AddTextBox.Height;
         addcontrolarge.ITEM_TYPE   = "TextBoxText";//默认给个普通文本框
         addcontrolarge.ITEM_WIDTH  = AddTextBox.Width;
         addcontrolarge.MULTILINE   = "是";
         addcontrolarge.POS_X       = AddTextBox.Location.X;
         addcontrolarge.POS_Y       = AddTextBox.Location.Y;
         addcontrolarge.TAB_INDEX   = AddTextBox.TabIndex.ToString();
         addcontrolarge.WORD_WRAP   = "是";
         EditEventReferences.ActiveEditAddControlEvent(addcontrolarge);//触发添加控件事件
     }
     catch (Exception err) { MessageBox.Show(err.ToString()); }
 }
예제 #3
0
        /// <summary>
        /// 添加控件时
        /// </summary>
        /// <param name="args">添加控件的信息</param>
        void EditEventReferences_EditAddControlEvent(EditTemplateAddControlArgs args)
        {
            //DataGridView在数据绑定下无法添加行|从数据源添加
            DataTable addtb = LoadCustomControlList(EditName);
            DataRow   row   = addtb.NewRow();

            row["TAB_INDEX"]   = args.TAB_INDEX;
            row["ITEM_CNAME"]  = args.ITEM_CNAME;
            row["ITEM_ENAME"]  = args.ITEM_ENAME;
            row["ITEM_WIDTH"]  = args.ITEM_WIDTH;
            row["ITEM_HEIGHT"] = args.ITEM_HEIGHT;
            row["POS_X"]       = args.POS_X;
            row["POS_Y"]       = args.POS_Y;
            row["MULTILINE"]   = args.MULTILINE;
            row["WORD_WRAP"]   = args.WORD_WRAP;
            row["ITEM_TYPE"]   = args.ITEM_TYPE;
            addtb.Rows.Add(row);
            Bt_enter_Click(null, null);
            DGV_CustomControlList.DataSource = LoadCustomControlList(EditName);
        }
 /// <summary>
 /// 触发添加控件事件
 /// </summary>
 /// <param name="args">控件信息</param>
 public static void ActiveEditAddControlEvent(EditTemplateAddControlArgs args)
 {
     EditAddControlEvent(args);
 }