diff --git a/JinYuan.Helper/ScanerHook.cs b/JinYuan.Helper/ScanerHook.cs index d0bc6c4..d136444 100644 --- a/JinYuan.Helper/ScanerHook.cs +++ b/JinYuan.Helper/ScanerHook.cs @@ -84,6 +84,7 @@ namespace JinYuan.Helper { EventMsg msg = (EventMsg)Marshal.PtrToStructure(lParam, typeof(EventMsg)); codes.Add(msg); + Debug.WriteLine($"scanerEvent: {codes.Result}, msg.message: {msg.message}, msg.paramH: {msg.paramH}"); if (ScanerEvent != null && msg.message == 13 && msg.paramH > 0 && !string.IsNullOrEmpty(codes.Result)) { ScanerEvent(codes); diff --git a/LargeSquareOne/CommunicationEditForm.cs b/LargeSquareOne/CommunicationEditForm.cs index ebef2d6..6e6a425 100644 --- a/LargeSquareOne/CommunicationEditForm.cs +++ b/LargeSquareOne/CommunicationEditForm.cs @@ -177,7 +177,13 @@ namespace LargeSquareOne { if (e.RowIndex < 0) return; - editingConfig = TotalGroups[e.RowIndex]; + // 获取当前行显示的数据 + var currentRow = groupTable.Rows[e.RowIndex]; + var config = (PlcGroupConfig)currentRow.DataBoundItem; + editingConfig = TotalGroups.First(g => + g.PlcNum == config.PlcNum && + g.GroupName == config.GroupName && + g.Start == config.Start); // 禁止编辑PLC编号和组名列 if (groupTable.Columns[e.ColumnIndex].Name == "PlcNum") @@ -193,7 +199,13 @@ namespace LargeSquareOne { if (e.RowIndex < 0 || e.RowIndex >= TotalGroups.Count) return; - var config = TotalGroups[e.RowIndex]; + // 获取当前行显示的数据 + var currentRow = groupTable.Rows[e.RowIndex]; + var curConfig = (PlcGroupConfig)currentRow.DataBoundItem; + var config = TotalGroups.First(g => + g.PlcNum == curConfig.PlcNum && + g.GroupName == curConfig.GroupName && + g.Start == curConfig.Start); var value = groupTable[e.ColumnIndex, e.RowIndex].Value; try