Solved

C# Refresh main form with Infragistic Control from another form

Posted on 2016-08-05
1
50 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 20

Accepted Solution

by:
Daniel Van Der Werken earned 500 total points
ID: 41744800
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

856 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