Browse Source

添加按钮事件先后顺序

章政 7 years ago
parent
commit
e568df75bc

+ 30 - 2
UAS_DeviceMonitor/CustomerControl/Button/ButtonSaveGrid.cs

@@ -9,6 +9,10 @@ namespace UAS_DeviceMonitor.CustomerControl.Button
     {
 
         private AutoDataGridControl.AutoDataGridControl grid;
+        /// <summary>
+        /// 设置是否优先处理用户自定义的Click事件
+        /// </summary>
+        private bool handlerOtherFirst = false;
 
         public AutoDataGridControl.AutoDataGridControl Grid
         {
@@ -23,12 +27,28 @@ namespace UAS_DeviceMonitor.CustomerControl.Button
             }
         }
 
+        public bool HandlerOtherFirst
+        {
+            get
+            {
+                return handlerOtherFirst;
+            }
+
+            set
+            {
+                handlerOtherFirst = value;
+            }
+        }
+
         public ButtonSaveGrid()
         {
             InitializeComponent();
         }
 
-        private void ButtonSaveGrid_Click(object sender, EventArgs e)
+        /// <summary>
+        /// 处理完其他Click事件提供回调函数重新触发保存事件
+        /// </summary>
+        public void DoSave()
         {
             DataTable dt = ((DataTable)grid.DataSource).GetChanges();
             if (dt != null && dt.Rows.Count > 0)
@@ -42,5 +62,13 @@ namespace UAS_DeviceMonitor.CustomerControl.Button
                 XtraMessageBox.Show("没有修改过的数据", "提示");
             }
         }
+
+        private void ButtonSaveGrid_Click(object sender, EventArgs e)
+        {
+            if (!handlerOtherFirst)
+            {
+                DoSave();
+            }
+        }
     }
-}
+}

+ 4 - 0
UAS_DeviceMonitor/Main.Designer.cs

@@ -453,11 +453,13 @@ namespace UAS_DeviceMonitor
             // 
             this.ButtonSaveCommand.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
             this.ButtonSaveCommand.Grid = null;
+            this.ButtonSaveCommand.HandlerOtherFirst = true;
             this.ButtonSaveCommand.Location = new System.Drawing.Point(956, 551);
             this.ButtonSaveCommand.Name = "ButtonSaveCommand";
             this.ButtonSaveCommand.Size = new System.Drawing.Size(64, 23);
             this.ButtonSaveCommand.TabIndex = 2;
             this.ButtonSaveCommand.Text = "保存";
+            this.ButtonSaveCommand.Click += new System.EventHandler(this.ButtonSaveCommand_Click);
             // 
             // GridCommandSetting
             // 
@@ -593,6 +595,7 @@ namespace UAS_DeviceMonitor
             // 
             this.ButtonSaveCommandSet.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
             this.ButtonSaveCommandSet.Grid = null;
+            this.ButtonSaveCommandSet.HandlerOtherFirst = false;
             this.ButtonSaveCommandSet.Location = new System.Drawing.Point(956, 549);
             this.ButtonSaveCommandSet.Name = "ButtonSaveCommandSet";
             this.ButtonSaveCommandSet.Size = new System.Drawing.Size(64, 23);
@@ -793,6 +796,7 @@ namespace UAS_DeviceMonitor
             // 
             this.ButtonSavePolling.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
             this.ButtonSavePolling.Grid = null;
+            this.ButtonSavePolling.HandlerOtherFirst = false;
             this.ButtonSavePolling.Location = new System.Drawing.Point(949, 551);
             this.ButtonSavePolling.Name = "ButtonSavePolling";
             this.ButtonSavePolling.Size = new System.Drawing.Size(64, 23);

+ 15 - 29
UAS_DeviceMonitor/Main.cs

@@ -56,9 +56,6 @@ namespace UAS_DeviceMonitor
             ButtonDeleteCommand.Grid = GridCommandSetting;
         }
 
-
-
-
         #region 界面通用事件
         /// <summary>
         /// 选项卡切换不同XPage
@@ -85,32 +82,6 @@ namespace UAS_DeviceMonitor
             }
         }
 
-        private void ItemComboBox_ParseEditValue(object sender, DevExpress.XtraEditors.Controls.ConvertEditValueEventArgs e)
-        {
-            e.Value = e.Value.ToString(); e.Handled = true;
-        }
-
-        /// <summary>
-        /// Grid中的ComboBox的值设置
-        /// </summary>
-        /// <param name="sender"></param>
-        /// <param name="e"></param>
-        private void ItemComboBox_SelectedIndexChanged(object sender, EventArgs e)
-        {
-            ComboBoxEdit combox = sender as ComboBoxEdit;
-            //ComboBoxData combodata = (ComboBoxData)(combox).SelectedItem;
-            GridControl grid = combox.Parent as GridControl;
-
-            combox.EditValue = "TEST";
-
-            ////Console.WriteLine(combox.EditValue.GetType());
-            GridView myView = (grid.MainView as GridView);
-            myView.SetRowCellValue(myView.FocusedRowHandle, myView.FocusedColumn.Name, "123123");
-            combox.Text = "1231";
-            //DataTable dt = (DataTable)grid.DataSource;
-            //dt.Rows[myView.FocusedRowHandle][myView.FocusedColumn.Name.ToUpper()] = combodata.Value;
-        }
-
         /// <summary>
         /// 勾选Grid的CheckBox
         /// </summary>
@@ -160,6 +131,16 @@ namespace UAS_DeviceMonitor
             GridCommandSetting.RefreshData();
         }
 
+        /// <summary>
+        /// 判断指令编号不能重复
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void ButtonSaveCommand_Click(object sender, EventArgs e)
+        {
+            ButtonSaveCommand.DoSave();
+        }
+
         /// <summary>
         /// 加载ComBox品牌数据
         /// </summary>
@@ -194,6 +175,11 @@ namespace UAS_DeviceMonitor
 
         }
 
+        /// <summary>
+        /// 设置GridView下拉框的值
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
         private void PagePollingSetting_VisibleChanged(object sender, EventArgs e)
         {
             if (PagePollingSetting.PageVisible)