0
我在保持ListView控件的SelectedItem中的前一個值時遇到了一些麻煩。 我使用EXCEL VBA UserForm來顯示錶格內容並允許對列進行編輯。 但是,我無法保持之前的值。更新後,該值將爲空白。如果新值是一個空字符串,VBA ListView保持以前的值
任何想法? 謝謝!
Dim valBeforeEdit As String
Private Sub listviewOBJ_AfterLabelEdit(Cancel As Integer, NewString As String)
If NewString <> "" Then
'Update database with new value
MsgBox "updated to " & NewString
Else
listviewOBJ.SelectedItem = valBeforeEdit
'Put the value back to whatever it was before user erased it to blank ""
End If
End Sub
Private Sub listviewOBJ_BeforeLabelEdit(Cancel As Integer)
valBeforeEdit = listviewOBJ.SelectedItem
End Sub
太棒了,謝謝! – JTFRage