Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Using CWNumEdit Control from Measurement Studio with VS .Net 2003

I have a bunch of CWNumEdit controls that I want to populate from data within a file.  But when I go to execute these lines of code I get an error message of

An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll

Additional information: Property is read-only

I am not sure how to get around this error since I thought I should be able to populate the control from normal user input.  If someone knows away to properly populate the control please let me know.

Thanks.
0 Kudos
Message 1 of 6
(7,251 Views)
Hi mtd32610,
 
How are you trying to populate the CWNumEdit control? What is the line that gives you the error message?
 
The normal way to populate the control is to use:
<control>.Value = <numeric_value>;
 
You can see an example of doing this in the Measurement Studio shipping example for Visual C++ located at:
C:\Documents and Settings\All Users\Documents\National Instruments\MStudioVS2003\VCNET\Examples\UI\NumEdit\Simple Numeric
Jervin Justin
NI TestStand Product Manager
0 Kudos
Message 2 of 6
(7,208 Views)
Jervin,
    The following line is what is causing the problem
        axCWNE_TOTAL->set_Text(Convert::ToString(m_pMyStruct->uTotal));

    The application is a WinForm developed in VS .Net 2003 with C++ and for some reason the numerical edit boxes won't work right.  The program just seems to stop executing there for some reason.  I thought I should be able to populate it with no problem.
0 Kudos
Message 3 of 6
(7,194 Views)
What type of object does the axCWNE_TOTAL pointer reference?  I believe you are calling the set_Text method on the wrong object.  Furthermore, as mentioned earlier in this post and on this forum, you do not need to call the set_Text method at all to update the value of a CWNumEdit control.  You simply need to set the "Value" property for the variable associated with your control.  This variable should be of type CNiNumEdit.

Follow these steps to create a CWNumEdit control that you can update:
1. Drag a CWNumEdit control onto the dialog from the Measurement Studio palette.
2. "Add a Variable" for this control and name it appropriately.
3. In your code, call
<control name>.Value = <new value>;
to update the value of your numeric edit control.  The expected type of <new value> is a double, not a string.

I hope that helps!


Message Edited by Marty_H on 06-12-2008 09:57 AM
Regards,


Marty H.
National Instruments
0 Kudos
Message 4 of 6
(7,183 Views)
The application is a Winform and so when I drag the control to the window, a control variable is create automatically for you.
The variable is  AxInterop::CWUIControlsLib::AxCWNumEdit *  axCWNE_TOTAL.  I access the set functions for other controls and it does cause any issues, only the numerical edit controls.
0 Kudos
Message 5 of 6
(7,179 Views)
Thanks for the update.  Even though you are using a WinForm, you are still going to set the 'Value' property for this object.  You will probably need to put your integer/double value inside the __box() method.  This will create a managed object on the heap that can be used to update your control.  So your statement to update the control should look something like this:

axCWNE_TOTAL->Value = __box( <numeric value> ) ;

Regards,


Marty H.
National Instruments
0 Kudos
Message 6 of 6
(7,173 Views)