Message 1 of 15
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I found this great example on how to create a modeless form. One thing I cant figure out is how to retrieve text from the ComboBox in in the external event?
Problem: new Form1(x,y).show(); is declared inside the class FormShow : IExternalCommand and the Transaction is happening in the class ExHandler : IExternalEventHandler
Is there a way to create a some sort of a global string variable, and when a user clicks a button it sets that variable to
ComboBox selection? How would I declare that so I could pull this variable in external event? My form, application, and the command are all on different C# files in the solution. This makes my brain hurt 🤕
[Transaction(TransactionMode.Manual)]
class FormShow : IExternalCommand
{
public Result Execute(ExternalCommandData c, ref string m, ElementSet e)
{
ExternalEvent x = ExternalEvent.Create(new ExHandler());
UIApplication u = c.Application;
new Form1(x, u).Show();
return Result.Succeeded;
}
class ExHandler : IExternalEventHandler
{
public void Execute(UIApplication ap) { }
public string GetName() { "form1" }
}
}
class Form1 : Form
{
ExternalEvent x;
UIApplication u;
Document d;
public Form1(ExternalEvent e, UIApplication a)
{
InitializeComponent();
x = e;
u = a;
d = u.ActiveUIDocument.Document;
}
private void Button1_Click(object sender, EventArgs e)
{
x.Raise();
using (Transaction t = new Transaction(d, "command"))
{
t.Start();
//do something
t.Commit();
}
this.Close();
}
}
The definition of insanity is doing the same thing over and over again and expecting different results
Solved! Go to Solution.