Modelless Second Form

Modelless Second Form

thannaingoo.api
Advocate Advocate
512 Views
1 Reply
Message 1 of 2

Modelless Second Form

thannaingoo.api
Advocate
Advocate

Dear Developer,

 

I am trying to use the modelless form to be modify the model although the form was open.

 

I can access the model to modify when the first form was open.

 

Form1.JPG

 

I cannot access the model when the form2 is up.

 

Form2.JPG

 

Kindly help me, How should be do for form2 to be access the model?

 

Below code is how I load the form2,

 

using System;
using System.Windows.Forms;

namespace Revit.SDK.Samples.ModelessForm_IdlingEvent.CS
{
    public partial class ModelessForm : Form
    {
        private Request m_request;

        public Request Request
        {
            get
            {
                return m_request;
            }
            private set
            {
                m_request = value;
            }
        }

        public ModelessForm()
        {
            InitializeComponent();
            Request = new Request();
        }

        private void EnableCommands(bool status)
        {
            foreach (Control ctrl in this.Controls)
            {
                ctrl.Enabled = status;
            }
            if (!status)
            {
                this.btnExit.Enabled = true;
            }
        }

        private void MakeRequest(RequestId request)
        {
            Request.Make(request);
            DozeOff();
        }

        private void DozeOff()
        {
            EnableCommands(false);
        }

        public void WakeUp()
        {
            EnableCommands(true);
        }

        private void btnExit_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void btn_form2_Click(object sender, EventArgs e)
        {
            this.Close();
            Form2 f2 = new Form2();
            f2.ShowDialog();
        }
    }
}

Thanks Advance,

Naing Oo

 

 

 

 

0 Likes
513 Views
1 Reply
Reply (1)
Message 2 of 2

RPTHOMAS108
Mentor
Mentor

I don't know what you mean by interact with model: read/write via API while the form is showing or interact with UI?

 

The second form is called with ShowDialog instead of Show, so it will be modal not modeless.

 

 

0 Likes