Autodesk Inventor (3D 描画ソフトウェア) 用のアドインを作成しています。現在、位置の制約をいじっています。
特定の値 (この場合は標高と方向の値) をすばやく編集するためのカスタム ユーザー メニューを作成しました。
最初に、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