Hi All,
Im new to C# and having an issue with MessageBoxIcon.
I am trying to use the same piece of code to show a message box which will need to display the appropriate icon ie error or exclamation etc.
In the example below, you can see that the icon name is hard coded as "Exclamation". What I would like to do is use the variable "str3" to tell the MessageBox which icon to display. Is this possible?
using System;
using System.Text;
using System.Windows.Forms;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.DatabaseServices;
[assembly: CommandClass(typeof(Autodesk.AutoCAD.MsgBox.STDLMessageBox))]
namespace Autodesk.AutoCAD.MsgBox
{
public class STDLMessageBox
{
[LispFunction("ConcatStrings")]
static public string ConcatStrings(ResultBuffer args)
{
Array ArgsArray = args.AsArray();
string str1 = Convert.ToString(((TypedValue)(ArgsArray.GetValue(0))).Value);
string str2 = Convert.ToString(((TypedValue)(ArgsArray.GetValue(1))).Value);
string str3 = Convert.ToString(((TypedValue)(ArgsArray.GetValue(2))).Value);
MessageBox.Show(str1, str2, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return null;
}
}
}
Loading
Danatas GerviPosted Oct 29, 2009, 6:56 AM
use this:
MessageBoxIcon iconParsed = (MessageBoxIcon)Enum.Parse(typeof(MessageBoxIcon), str3);
Steve RuddPosted Oct 29, 2009, 6:09 AM
naura paxPosted Oct 29, 2009, 5:31 AM
pardon me this is just a vague attempt - you can create your own type and use it in application eg. I have not tested it yet (you can have standard if-else construct otherwise).
theLizardPosted Oct 29, 2009, 5:21 AM
switch(option)
{
case 1:
icon = MessageBoxIcon.Exclamation;
break;
}
MessageBox.Show("Hello", "there", MessageBoxButtons.OK, icon);
theLizardPosted Oct 29, 2009, 5:21 AM
switch(option)
{
case 1:
MessageBoxIcon.Exclamation;
break;
}
MessageBox.Show("Hello", "there", MessageBoxButtons.OK, icon);