Showing results for 
Search instead for 
Do you mean 
Reply
Solved! Go to solution

Show String Array in NXMessagebox C# NXOpen

[ Edited ]

Hi

i want to show a string Array in a NXmessagebox.

Is there possibility to do that ?

 

 

3 REPLIES

Re: Show String Array in Messagebox C# NXOpen

Hello,

just a quick reply showing an extension to form a single string out of an array:

 

        /// <summary>                                                           
        /// Joins an array of strings using a separator
        /// </summary>                                                          
        /// <param name="texts">the array to join</param>                     
        /// <param name="separator">separator in use (e.g. "\r\n")</param>        
        /// <param name="startIndex">start index of the string array</param>
        /// <returns>joined text</returns>                        
        public static string ToSingleString(this string[] texts, string separator, int startIndex)
        {
            var sb = new System.Text.StringBuilder();

            for (int ii = startIndex; ii < texts.Length; ii++)
            {
                sb.Append(texts[ii]);
                if (ii < texts.Length - 1)
                {
                    sb.Append(separator);
                }
            }
            return sb.ToString();
        }

 

This joined string you can send to a message box (another extension):

        /// <summary>                                                           
        /// Displays an information box on the screen
        /// </summary>                                                          
        /// <param name="message">text to show</param>                  
        /// <param name="title">title to be displayed</param>                    
        public static void MessageBox(this string message, string title)
        {
            System.Windows.Forms.MessageBox.Show(message, 
                title,
                System.Windows.Forms.MessageBoxButtons.OK,
                System.Windows.Forms.MessageBoxIcon.Information);
        }

 

 

 

Hope this helps.

Herbert Macho
EBNER Industrieofenbau
AUSTRIA

NX10.0.3.5 (TeamCenter10 and Native)

Re: Show String Array in Messagebox C# NXOpen

No need to write your own. Simply use the .Net String.Join method

 

String.Join Method (String, String[])

Solution
Solution
Accepted by topic author Ildon
‎06-30-2016 01:23 AM

Re: Show String Array in NXMessagebox C# NXOpen

"i want to show a string Array in a NXmessagebox.

Is there possibility to do that"

 

Yes, the NXMessagebox has an overloaded .Show method that will accept a string array as input for the message.