Solved

C# Refresh main form with Infragistic Control from another form

Posted on 2016-08-05
1
26 Views
Last Modified: 2016-08-05
When my main form (winform) loads it is using an infragistics control.  I'm using Tiles.  A user clicks on a tile and navigates to a windows form.  The user is allowed to add data which is stored in an XML document.  When the user does this I need to refresh the main form to add new tiles to the main form.

Any idea how to do this from another winform?
0
Comment
Question by:CipherIS
1 Comment
 
LVL 19

Accepted Solution

by:
Daniel Van Der Werken earned 500 total points
Comment Utility
Okay. I think this is a generic way for you to work this out.

Expose a public method on the first winform as I'm showing here:

    public partial class Form1 : Form
    {
        public void DoSomething()
        {
            GroupBox gb = (GroupBox)Controls.Find("form1GroupBox1", true).FirstOrDefault();

            if (gb != null)
            {
                CheckBox cb = new CheckBox();
                cb.Name = "My New Checkbox";
                cb.Text = "Some awesome checkbox";
                cb.Checked = true;

                gb.Controls.Add(cb);
            }
        }

        public Form1()
        {
            InitializeComponent();


        }

        private void btnNewForm_Click(object sender, EventArgs e)
        {
            Form2 form2 = new Form2();
            form2.Show();
        }
    }

Open in new window


Then, on the second form, you need to grab hold of the first form and call it.

    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        private void btnAddControl_Click(object sender, EventArgs e)
        {
            FormCollection fc = Application.OpenForms;
            
            foreach(var f in fc)
            {
               if (f.GetType() == typeof(Form1))
                {
                    Form1 form = (Form1)f;
                    form.DoSomething();
                }
            }
        }
    }

Open in new window


Form1 had a button and a group box. Form2 just had a button. I dynamically added a control to Form1 as shown.

You should be able to do something similar to this very thing that I'm showing with what you're looking to do.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now