Highlight a component from the Windows Form

Good evening

1. Get a component in the SelectObject in main module
2. Component, it will stored in the Public comp As Component of Win Form Class
3. It will display the Win Form in Form.ShowDialog
4. Run comp.Highlight() method. However, it does not highlight

In DisplayPart.ModelingViews.WorkView.Fit ()
Screen it will highlight and move even a little.
Can you highlight without moving the screen.

NX9

I've not tried it, but what if you highlight it before the winform is shown?

Always thank you.

I make a command to edit the part attribute of the assembly
I display a part attribute in DataGridView of WinFrom
When there are many components; of DataGridView
I want to let you do a highlight which part of the screen a list is
When I click DataGridView Row
A highlight is device to do
I wrote a brief sample in ListBox
I am encoding it
'DisplayPart.ModelingViews.WorkView.Fit()
A highlight assumes that I cancel comment
The screen just wants to do a highlight
Is there a solution?

Option Strict Off
Option Explicit On

Imports System
Imports System.Windows.Forms
Imports System.Collections.Generic

Imports NXOpen
Imports NXOpen.Assemblies

Module NXJournal
Dim theSession As Session = Session.GetSession()
Sub Main()
Dim form As New Form1(theSession)
form.ShowDialog()
End Sub
End Module

<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form1
Inherits System.Windows.Forms.Form

Private theSession As Session
Private DisplayPart As Part
Private ComponentList As New list(Of Component)
Private ComponentName As New List(Of String)

Public Sub New(ByVal NewSession As Session)
InitializeComponent()
theSession = NewSession
DisplayPart = theSession.Parts.Display
End Sub

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
Dim c As ComponentAssembly = DisplayPart.ComponentAssembly
ComponentLoop(c.RootComponent)
ListBox1.Items.AddRange(ComponentName.ToArray)
End Sub

Private Sub ComponentLoop(ByVal comp As Component)
ComponentList.Add(comp)
ComponentName.Add(comp.DisplayName)
For Each child As Component In comp.GetChildren()
ComponentLoop(child)
Next
End Sub

Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListBox1.SelectedIndexChanged
Static PrevComp As Component
If Not IsNothing(PrevComp) Then PrevComp.Unhighlight()
PrevComp = ComponentList(ListBox1.SelectedIndex)
PrevComp.Highlight()
'DisplayPart.ModelingViews.WorkView.Fit()
End Sub

<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub

Private components As System.ComponentModel.IContainer

<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.ListBox1 = New System.Windows.Forms.ListBox()
Me.SuspendLayout()
'
'ListBox1
'
Me.ListBox1.Dock = System.Windows.Forms.DockStyle.Fill
Me.ListBox1.FormattingEnabled = True
Me.ListBox1.ItemHeight = 12
Me.ListBox1.Location = New System.Drawing.Point(0, 0)
Me.ListBox1.Name = "ListBox1"
Me.ListBox1.Size = New System.Drawing.Size(284, 262)
Me.ListBox1.TabIndex = 0
'
'Form1
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 12.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(284, 262)
Me.Controls.Add(Me.ListBox1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)

End Sub
Friend WithEvents ListBox1 As System.Windows.Forms.ListBox

End Class

The .UpdateDisplay method seems to work.

Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListBox1.SelectedIndexChanged
Static PrevComp As Component
If Not IsNothing(PrevComp) Then PrevComp.Unhighlight()
PrevComp = ComponentList(ListBox1.SelectedIndex)
PrevComp.Highlight()
DisplayPart.ModelingViews.WorkView.UpdateDisplay()
End Sub

I was able to do it
Thank you very much!!