Solved

C# Refresh main form with Infragistic Control from another form

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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
I need help writing Unit Tests for my ASP.Net MVC application 5 40
EF5 How do I stop pre-compiled views? 8 52
C# Change the instruction to user. 11 39
C# LINQ query question 11 30
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
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…

734 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