NXKnowledge

Community Knowledge > Best Practices

Message Boxes and the Listing Window: NXOpen vs .NET Approaches

A small but frequently-asked practical question: when writing user-facing output from an NXOpen tool, should you use NXOpen's own message box API, .NET's MessageBox, or the NX Listing Window? NX Journaling's community articles lay out the trade-offs.

NXOpen message boxes vs .NET message boxes

  • Visual theme: an NXOpen message box automatically matches NX's own application theme; a .NET (Windows Forms) message box follows whatever the Windows OS theme/settings are, so it can look visually inconsistent with NX.
  • Flexibility: .NET message boxes are described as "more flexible," though for most simple cases either works fine.
  • When you're forced into NXOpen's version: on Linux versions of NX, Microsoft's .NET libraries aren't available, so NXOpen's own message box API is the only option there — a portability consideration that matters if a tool needs to run cross-platform.
  • A specific documented bug: multi-line text doesn't reliably display in NXOpen input boxes. One developer reported that using vbCrLf to break an input box message into multiple lines resulted in only the first line showing, with the rest running into the input line itself. The fix reported was to switch to a Windows Forms input box instead, which handled multi-line text correctly. If a tool needs to show more than a one-line prompt/message and doesn't need Linux portability, prefer .NET dialogs for that reason alone.

Listing Window basics

The Listing Window is NX's built-in scrollable text/output window, and it's the default output device when a journal doesn't explicitly select another device. A practical tip from the community: if you want output to go only to the Listing Window and not also be duplicated to a text file, comment out or remove any .SelectDevice calls in your code that redirect output to a file — some recorded/example journals write to both simultaneously by default, and it's easy to leave that in when adapting example code for a different purpose.

A cited practical use case: rather than dumping datum/GD&T data to an external Excel file (a heavier, slower round trip), several examples in the community favor writing that data straight to the Listing Window for immediate, in-application viewing — useful for diagnostic or ad hoc reporting tools where a separate file isn't actually needed.

Practical takeaway

  • Default to NXOpen message boxes for single-line, theme-consistent prompts, especially if Linux support matters.
  • Switch to Windows Forms dialogs as soon as you need multi-line text or richer input controls — the NXOpen message box's multi-line handling is unreliable.
  • Double-check .SelectDevice calls when reusing example/recorded code — you may be silently also writing to a text file when you only intended Listing Window output.

Source: https://www.nxjournaling.com/content/using-message-boxes ; https://nxjournaling.com/content/listing-window · retrieved 2026-07-08