Message 1 sur 3

Non applicable
01-19-2016
12:40 AM
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Lien permanent
- Imprimer
- Signaler
Hi, I'm working with a dockable window and discovered a problem with focusing on the text box. When clicking a tree node, the name is written in the textbox and it shall be focused and all selected. Unfortunately the textbox doesn't keep the focus. I tried already with the debugger. There I discovered that the focus is really set to the textbox, but then it got lost immediately. Attached Is a picture of my dockable window and the code. I hope you can help me. Public Class Form1 Private invApp As Inventor.Application Private activeDoc As Inventor.AssemblyDocument Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load invApp = InventorAddInDWTest1.StandardAddInServer.m_inventorApplication Label1.Text = "TextBox1:" End Sub Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click Try If invApp.ActiveDocumentType = Inventor.DocumentTypeEnum.kAssemblyDocumentObject Then activeDoc = invApp.ActiveDocument Dim topNode As New TreeNode(activeDoc.DisplayName) For Each occ As ComponentOccurrence In activeDoc.ComponentDefinition.Occurrences Dim node As New TreeNode(occ.Name) topNode.Nodes.Add(node) Next TreeView1.Nodes.Add(topNode) TreeView1.ExpandAll() Else TreeView1.Nodes.Clear() activeDoc = Nothing TextBox1.Clear() Exit Sub End If Catch ex As Exception End Try End Sub Private Sub TreeView1_NodeMouseClick(sender As Object, e As TreeNodeMouseClickEventArgs) Handles TreeView1.NodeMouseClick Try Dim node As TreeNode = e.Node TextBox1.Text = node.Text TextBox1.Focus() Catch ex As Exception End Try End Sub Private Sub TextBox1_GotFocus(sender As Object, e As EventArgs) Handles TextBox1.GotFocus Label1.Text = "TextBox1: Focus" TextBox1.SelectAll() End Sub Private Sub TextBox1_LostFocus(sender As Object, e As EventArgs) Handles TextBox1.LostFocus Label1.Text = "TextBox1: Focus lost" End Sub End Class Thanks Andreas
Résolu ! Accéder à la solution.