Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Addin - Forms

NachitoMax
Advisor

Addin - Forms

NachitoMax
Advisor
Advisor

Hey

 

Whats the general cencus on how forms are managed for an addin? Im having issue getting the right. Originally i declared my form in AddinGlobal as a New form but thats not right as it should be instantiated until needed.

 

Public MyForm As New MyMainForm

So, i changed it to a declare and instantiated in under the button click

'in AddinGlobal
Public MyForm As MyMainForm

'in button click
AddinGlobal.MyForm = New MyMainForm

But im getting issues as i have sime other forms that get added to my main form that require access to properties and functions of the Mainform. however because it hasnt been instantiated, i get a bunch of errors.

 

What are other people doing to load forms in their addins?

 

Thanks

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


0 Likes
Reply
303 Views
1 Reply
Reply (1)

yan.gauthier
Advocate
Advocate

You need to separate your model (data structure) from your logic and from your view (your form)

Example (C#) :

public class Model()

{

    public string property (get; set;)

}

 

public class ViewModel()

{

    public BindingList<Model> myBindingList = new BindingList<Model>();

    myBindingList.add( new Model

    {

        property = "this property",

    });

{

 

public partial class View : Form

{

    public View(BindingList<Model> bindingList)

    {

        // Let say you have set a DataGridView in your Form Designer

        InitializeComponent();

        BindingSource bindingSource = new BindingSource(bindingList, "")

        dataGridView1.DataSource = BindingSource;

    }

}

 

In your ViewModel Class, you can subscribe your events and do all your logics. You should place as little code as possible in your forms.

 

In a way, You should try to setup a MVVM structure you would do in a WPF form.

 

This way, you never have properties and method in a form.

0 Likes