NI Home
Cart Cart | Help
Hello Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI
You are here: 
NI Home > NI Developer Zone > NI Discussion Forums


Reply
Active Participant
tonitpp
Posts: 394
0 Kudos
Accepted Solution

Host a PropertyEditor in a DataGridView cell

Hi all,

 

I am using Net Measurement Studio in C# and I would like to know how can I host a PropertyEditor (for example, LineStyle as property for a plot object) in a DataGridView cell. Is it possible? how can I achieve this?

 

Thanks.

Active Participant
tonitpp
Posts: 394
0 Kudos

Re: Host a PropertyEditor in a DataGridView cell

Hi,

 

I have hosted a PropertyEditor into a datagridviewcolumn as a custom cell following the below approach:

 

http://msdn.microsoft.com/en-us/library/7tas5c80.aspx

 

but when my datagridview is loaded (columns/rows created), cell of type PropertyEditor are not visible until you do double-click. Also after double click below error is generated inmediatelly (in this case I have a propertyeditor whose source is object=ScatterPlot, propertyName=LineStep.

 

Error Details:

The type initializer for 'NationalInstruments.UI.Internal.WaveformPlotElement' threw an exception.The type initializer for 'NationalInstruments.PrecisionTimeSpan' threw an exception.Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.

Stack Trace:

   at NationalInstruments.UI.Internal.WaveformPlotElement..ctor(Object obj)
   at NationalInstruments.UI.WaveformPlot.CreateElement()
   at NationalInstruments.UI.ControlEntity..ctor()
   at NationalInstruments.UI.Plot..ctor()
   at NationalInstruments.UI.CartesianPlot..ctor()
   at NationalInstruments.UI.XYPlot..ctor()
   at NationalInstruments.UI.XYPlot..ctor(XAxis xAxis, YAxis yAxis)
   at NationalInstruments.UI.WaveformPlot..ctor(XAxis xAxis, YAxis yAxis)
   at NationalInstruments.UI.Internal.Design.LineStepEditor.Draw(Graphics graphics, Rectangle bounds, Object item)
   at NationalInstruments.Internal.Design.PreviewDropDownEditor.DrawPreview(Graphics graphics, Rectangle bounds, Object item)
   at NationalInstruments.Internal.Design.PreviewDropDownEditor.PaintValue(PaintValueEventArgs e)
   at NationalInstruments.UI.WindowsForms.PropertyEditor.b.a(PaintEventArgs A_0)
   at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer)
   at System.Windows.Forms.Control.WmPaint(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

 

I am trying to solve two issues:

 

1) Why custom PropertyEditor cell is not visible?

2) Why after doubleclick on cell it crashes with the above message?

 

Thanks.

Active Participant
tonitpp
Posts: 394
0 Kudos

Re: Host a PropertyEditor in a DataGridView cell

By adding useLegacyV2RuntimeActivationPolicy="true" to app.config file in the project solved it.

 

<startup useLegacyV2RuntimeActivationPolicy="true">

            <supportedRuntime version="v4.0"/>

</startup>



 

By using this web site, you accept the Terms of Use for this web site. Please read these Terms of Use carefully before using any part of this site. Please go here for information on ni.com's copyright infringement policy.
My Profile | Privacy | Legal | Contact NI © 2011 National Instruments Corporation. All rights reserved.    |    E-Mail this Page E-Mail this Page