Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

C# Refresh main form with Infragistic Control from another form

Posted on 2016-08-05
1
Medium Priority
?
96 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 20

Accepted Solution

by:
Daniel Van Der Werken earned 2000 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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

636 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