wyq 1 жил өмнө
parent
commit
2799d76d22

+ 34 - 1
XdCxRhDW.App/EditForms/TarDfoLeoX2Calc.cs

@@ -1,4 +1,5 @@
-using ExtensionsDev;
+using DevExpress.XtraEditors;
+using ExtensionsDev;
 using System;
 using System.Collections.Generic;
 using System.Data.Entity;
@@ -27,7 +28,14 @@ namespace XdCxRhDW.App.EditForms
             this.Text = "两星频差预测";
             this.layoutControl1.UseDefault();
             this.StartPosition = FormStartPosition.CenterParent;
+            this.listBoxRes.SelectionMode = SelectionMode.MultiSimple;
+            this.listBoxRes.SelectedIndexChanged += ListBoxRes_SelectedIndexChanged;
+            // 处理键盘事件
+            this.listBoxRes.KeyDown += ListBoxRes_KeyDown;
+            // 允许listBox接收焦点
+            this.listBoxRes.TabStop = true;
         }
+
         public TarDfoLeoX2Calc(double lon, double lat)
             : this()
         {
@@ -120,6 +128,31 @@ namespace XdCxRhDW.App.EditForms
             }
 
 
+        }
+        private void ListBoxRes_KeyDown(object sender, KeyEventArgs e)
+        {
+            // 检查是否按下了Ctrl+C
+            if (e.Modifiers == Keys.Control && e.KeyCode == Keys.C)
+            {
+                // 如果是,复制选中的文本到剪贴板
+                UpdateClipboard();
+                e.Handled = true; // 标记事件已处理
+            }
+        }
+
+        // 更新剪贴板的内容
+        private void UpdateClipboard()
+        {
+            var selectedItems = listBoxRes.SelectedItems.Cast<string>();
+            var text = string.Join(Environment.NewLine, selectedItems);
+            if(!string.IsNullOrEmpty(text))
+            Clipboard.SetText(text);
+        }
+
+        private void ListBoxRes_SelectedIndexChanged(object sender, EventArgs e)
+        {
+            // 当选中项时更新剪贴板内容
+            UpdateClipboard();
         }
         private async void btnOk_Click(object sender, EventArgs e)
         {