NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a C# example of using the ExpressionEdit Control Custom Button Event Handler

Solved!
Go to solution

TestStand 4.1

C# 2008

 

I have added the event handler to the ExpressionEdit events as I would any event handler:

exprEdit.ButtonClick += new NationalInstruments.TestStand.Interop.UI.Ax._ExpressionEditEvents_ButtonClickEventHandler(_ExpressionEditEvents_ButtonClickEvent);

 

Next, I create the Event Handler using the syntax

public void _ExpressionEditEvents_ButtonClickEvent(NationalInstruments.TestStand.Interop.UI.ExpressionEditButton btn)

{

}

 

I get the following error when I try to build:

Error 1 No overload for '_ExpressionEditEvents_ButtonClickEvent' matches delegate 'NationalInstruments.TestStand.Interop.UI.Ax._ExpressionEditEvents_ButtonClickEventHandler' 

I assume this means that I don't have the correct parameters or types in my Event Handler declaration but it matches the Object Browser.  Any ideas on what I am missing?

 

 

0 Kudos
Message 1 of 7
(4,124 Views)
Try removing the "Ax." from your namespace qualifier as I marked below.  I think you want the one in just the UI namespace.
Edit: well not necessarily.  Is your exprEdit variable declared as "NationalInstruments.TestStand.Interop.UI.Ax.AxExpressionEdit" or as "NationalInstruments.TestStand.Interop.UI.ExpressionEdit"?
If it is an AxExpressionEdit then I think you will want your event handler to look like this:
void exprEdit_ButtonClick(object sender, NationalInstruments.TestStand.Interop.UI.Ax._ExpressionEditEvents_ButtonClickEvent e)
 -Jeff
 

skribling wrote:

TestStand 4.1

C# 2008

 

I have added the event handler to the ExpressionEdit events as I would any event handler:

exprEdit.ButtonClick += new NationalInstruments.TestStand.Interop.UI.Ax._ExpressionEditEvents_ButtonClickEventHandler(_ExpressionEditEvents_ButtonClickEvent);

 

Next, I create the Event Handler using the syntax

public void _ExpressionEditEvents_ButtonClickEvent(NationalInstruments.TestStand.Interop.UI.ExpressionEditButton btn)

{

}

 

I get the following error when I try to build:

Error 1 No overload for '_ExpressionEditEvents_ButtonClickEvent' matches delegate 'NationalInstruments.TestStand.Interop.UI.Ax._ExpressionEditEvents_ButtonClickEventHandler' 

I assume this means that I don't have the correct parameters or types in my Event Handler declaration but it matches the Object Browser.  Any ideas on what I am missing?

 

 


 

Message Edited by Jeff.A. on 06-11-2010 03:25 PM
Message Edited by Jeff.A. on 06-11-2010 03:28 PM
0 Kudos
Message 2 of 7
(4,123 Views)

It is an AxExpressionEdit.  Removing the .Ax results in the error:

Error 1 Cannot implicitly convert type 'NationalInstruments.TestStand.Interop.UI._ExpressionEditEvents_ButtonClickEventHandler' to 'NationalInstruments.TestStand.Interop.UI.Ax._ExpressionEditEvents_ButtonClickEventHandler' 

0 Kudos
Message 3 of 7
(4,120 Views)
Solution
Accepted by skribling

See my last edit but I think you want your event handler to look like this:

 

public void exprEdit_ButtonClick(object sender, NationalInstruments.TestStand.Interop.UI.Ax._ExpressionEditEvents_ButtonClickEvent e)

0 Kudos
Message 4 of 7
(4,118 Views)
Yes, that's it.  I had tried adding the 'object sender' parameter early on but was still having problems and never went back to it.
0 Kudos
Message 5 of 7
(4,115 Views)

Glad to hear it worked.  Also if you are developing in Visual Studio you should be able to use it's autocomplete feature to generate your event handler.  As soon as you type += after an event you can press tab to autocomplete that line, and then press tab again for it to generate your handler with the correct prototype.  I always use this to get the prototype correct and then I can come back and rename it if I want.

 

-Jeff

0 Kudos
Message 6 of 7
(4,111 Views)
Thanks for the tip.  I've always used tab to autocomplete the += line but never knew about the tab again to generate the handler.
0 Kudos
Message 7 of 7
(4,107 Views)