NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Calling ExpressionEdit and selecting text from VB.NET

I have a problem when using the ExpressionEdit control. When the control is displayed I would like to have the text expression hi-lighted so that anything newly typed or selected will automatically overwrite what is already there. The problem is when I call the SelectAll method of ExpressionEdit. This should select all the text but has no effect. When the control is displayed I only ever have the first character selected. Here is some example code, any ideas where I'm going wrong?


Public Sub TestExpressionEdit(ByVal objSeqContext As NationalInstruments.TestStand.Interop.API.SequenceContext)
Dim objExpEdit As NationalInstruments.TestStand.Interop.UI.ExpressionEdit
Dim poSeqContext As NationalInstruments.TestStand.Interop.API.PropertyObject
Dim bCancelled As Boolean

poSeqContext = objSeqContext.AsPropertyObject

objExpEdit = New NationalInstruments.TestStand.Interop.UI.ExpressionEdit
objExpEdit.Context = poSeqContext
objExpEdit.Text = "Step.Result.Numeric"
objExpEdit.SelectAll()
bCancelled = Not objExpEdit.DisplayBrowseExprDialog()

If Not bCancelled Then
Debug.WriteLine(objExpEdit.Text)
End If

objExpEdit = Nothing
poSeqContext = Nothing
End Sub
0 Kudos
Message 1 of 2
(2,892 Views)
It looks like the ExpressionEdit control window is not actually getting created. There's a couple things you can do. One is ensure the window is created by creating an AxExpressionEdit instead of a ExpressionEdit and placing the control in a container. The following code demonstrates this:

Public Sub TestExpressionEdit(ByRef f As Form, ByVal objSeqContext As NationalInstruments.TestStand.Interop.API.SequenceContext)
Dim objExpEdit As NationalInstruments.TestStand.Interop.UI.Ax.AxExpressionEdit
Dim poSeqContext As NationalInstruments.TestStand.Interop.API.PropertyObject
Dim bCancelled As Boolean

poSeqContext = objSeqContext.AsPropertyObject

objExpEdit = New NationalInstruments.TestStand.Interop.UI.Ax.AxExpressionEdit
f.Controls.Add(objExpEdit)
objExpEdit.Visible = False
objExpEdit.Context = poSeqContext
objExpEdit.Text = "Step.Result.Numeric"
objExpEdit.SelectAll()
bCancelled = Not objExpEdit.DisplayBrowseExprDialog()
f.Controls.Remove(objExpEdit)

If Not bCancelled Then
Debug.WriteLine(objExpEdit.Text)
End If

objExpEdit = Nothing
poSeqContext = Nothing
End Sub

However, if you just want to display the Expression Browser dialog box and do not need an ExpressionEdit control, you can do this by calling Engine.DisplayBrowseExprDialogEx().
0 Kudos
Message 2 of 2
(2,883 Views)