Add condition preview feature to enhance user experience

- Add txtConditionPreview textbox initialization in UserForm_Initialize
- Clear preview textbox when refreshing details panel
- Implement lstDetails_Change event handler for condition preview
- Display complete condition text when user clicks on list items
- Improve readability for long/complex condition expressions
- Add debug output for troubleshooting

This enhancement allows users to easily view the full condition text for each material entry in a dedicated preview textbox, addressing the issue of long conditions being difficult to read in the narrow list column.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Misaka_Company
2026-03-19 16:22:15 +08:00
parent 0a8f3708e7
commit 068ff5d465

View File

@@ -40,6 +40,11 @@ Private Sub UserForm_Initialize()
.ListStyle = fmListStyleOption .ListStyle = fmListStyleOption
End With End With
' 初始化预览文本框
On Error Resume Next
Me.txtConditionPreview.Text = ""
On Error GoTo 0
' 清理提示信息 ' 清理提示信息
Me.lblLog.Caption = "" Me.lblLog.Caption = ""
@@ -144,6 +149,11 @@ Public Sub RefreshDetailsPanel()
Me.lstDetails.Clear Me.lstDetails.Clear
Me.chkSelectAllDetails.value = False Me.chkSelectAllDetails.value = False
' 刷新列表时顺便清空预览框
On Error Resume Next
Me.txtConditionPreview.Text = ""
On Error GoTo 0
If Not Me.chkShowDetails.value Then Exit Sub ' 未开启显示明细则跳过 If Not Me.chkShowDetails.value Then Exit Sub ' 未开启显示明细则跳过
' 收集目前被勾选的宏观名称 ' 收集目前被勾选的宏观名称
@@ -171,6 +181,30 @@ Public Sub RefreshDetailsPanel()
Next rowObj Next rowObj
End Sub End Sub
' ==============================================================================
' 新增:处理列表框点击事件,将超长的选择条件发送到预览框自动换行显示
' ==============================================================================
Private Sub lstDetails_Change()
' ListIndex 在多选模式下代表当前具有虚线焦点框的行
If Me.lstDetails.ListIndex >= 0 Then
On Error Resume Next
' 获取隐藏列中的物理行号
Dim targetId As Long
targetId = CLng(Me.lstDetails.List(Me.lstDetails.ListIndex, 0))
' 去内存库里抓取完整的 Condition赋值给预览框
Dim rowObj As cBOMRow
For Each rowObj In mGlobalBOMs
If rowObj.ExcelRowIndex = targetId Then
Me.txtConditionPreview.Text = rowObj.Condition
Debug.Print rowObj.Condition
Exit For
End If
Next rowObj
On Error GoTo 0
End If
End Sub
' ============================================================================== ' ==============================================================================
' 4. 执行核心流水线 ' 4. 执行核心流水线
' ============================================================================== ' ==============================================================================