Autodesk Inventor (3D 드로잉 소프트웨어) 용 AddIn을 만들고 잠시 동안 위치 제약 조건을 가지고 놀고 있습니다.버튼을 눌렀을 때 입력란 유효성 확인
특정 값 (이 경우 고도와 방향 값)을 빠르게 편집 할 수있는 사용자 지정 사용자 메뉴를 만들었습니다.
첫 번째로 textbox.textchanged
이벤트를 사용하여 제한 조건 값을 변경했습니다. 그러나 이것은 100 %가 아니 었습니다. 예를 들어 고도 1000을 누르면 표고가 4 번 (자리마다) 변경됩니다.
이제 validated event
을 사용했습니다. 이 더 나은 작동하지만 Enter
단추를 누르면 유효성 검사를 시작할 텍스트 상자를 갖고 싶습니다. 이것을 위해 나는 이것을 채웠다. 그러나 그것은 틀렸다. 나는 그것에 대해 확신한다. 어떻게 이것을 올바르게 써야합니까?
아래 코드는 작동하지만 결과를 얻으려면 적절한 방법을 갖고 싶습니다.
Private Sub tbElevationValue_TextChanged(sender As Object, e As EventArgs) _
Handles tbElevation.Validated
' If the elevation parameter and textbox value are the same
' The sub must be aborted
If CDbl(tbElevation.Text) = oElevationParameter.Value * 10 Then Exit Sub
' Check the entered value
Dim oValue As Double
If tbElevation.Text = "" Then
oValue = 0
tbElevation.Text = 0
Else
oValue = tbElevation.Text
End If
' Set the parameter value
oElevationParameter.Value = oValue/10
' Update the document
EM_AddIn.StandardAddInServer.m_inventorApplication.ActiveDocument.Update()
End Sub
Private Sub tbOrientation_TextChanged(sender As Object, e As EventArgs) _
Handles tbOrientation.Validated
' If the orientation parameter and textbox value are the same
' The sub must be aborted
If CDbl(tbOrientation.Text) = cRandiansToDegrees(oOrientationParameter.Value) Then Exit Sub
' Check the entered value
Dim oValue As Double
If tbOrientation.Text = "" Then
oValue = 0
tbOrientation.Text = 0
Else
oValue = tbOrientation.Text
End If
' Set the parameter value
oOrientationParameter.Value = cDegreesToRandians(oValue)
' Update the document
EM_AddIn.StandardAddInServer.m_inventorApplication.ActiveDocument.Update()
End Sub
Private Sub OrientationElevationEnterKey_Pressed(sender As Object, e As Windows.Forms.KeyEventArgs) Handles tbElevation.KeyUp, tbOrientation.KeyUp
If e.KeyCode = Windows.Forms.Keys.Enter Then
CType(sender, Windows.Forms.TextBox).Parent.Focus()
CType(sender, Windows.Forms.TextBox).Focus()
End If
End Sub
이는 내가 이벤트를 모니터링 할'텍스트 boxes'에없는 경우에도 각 시간이 키 입력이 이루어진 것을 초래하지 않음 이벤트가 트리거됩니다? 필요한 것보다 많은 리소스를 소비하지 않습니까? –
사실, KeyDown 이벤트 내에 테스트를 추가하여 현재 포커스가있는 컨트롤이 텍스트 상자 인 경우에만 폼에 포커스를 부여 할 수 있습니다 – theBugger