我想圈这样的无效数据:
当用户保存文档时,应显示圆圈,因此我创建了此功能:
class NotificationMappingAdmin(admin.ModelAdmin):
list_display = ['get_counterId', 'get_groupId',]
ordering = ('id',)
def get_form(self, request, obj=None, **kwargs):
form = super(NotificationMappingAdmin, self).get_form(request, obj, **kwargs)
form.base_fields['get_counterId'].queryset = CounterDetails.objects.all().order_by('-id')
form.base_fields['get_groupId'].queryset = CounterGroup.objects.all().order_by('-id')
return form
...并将其添加到Private Function clearInvalidCircles(sheetName)
With Sheets(sheetName)
.ClearCircles
ShapesBefore = .Shapes.Count
.CircleInvalid
ShapesAfter = .Shapes.Count
If ShapesAfter > ShapesBefore Then
MsgBox "Invalid entries are marked with a red circle, please change it to a valid input."
End If
End With
End Function
函数:
Workbook_BeforeSave
但是如果我想保存文档,它不会显示无效数据......
我调试了我的代码,发现Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
clearInvalidCircles "Sheet1"
End Sub
工作正常,并且在保存文档时(clearInvalidCircles
之后)
有没有更好的选择来避免这个问题?
非常感谢您的答案...