Am X

Hi,

I have created 2 winforms form1 and form2. form1 contains one check box. Form2 contains 2 panels. and inside the panel, i want add the form1's object. like below

Form1 objform = new Form1();

objform.TopLevel = false;

Form1 objform1 = new Form1();

objform1.TopLevel = false;

panel1.Controls.Add(objform);

objform.Show();

panel2.Controls.Add(objform1);

objform1.Show();

But when i do like this only the first panel shows form1 and nothing displays in 2nd panel

Also after displaying both the forms, when i check the checkbox in form1 in panel1, the check box of form1 in panel 2 should be checked.

How to achieve both the functionalities any idea...


Re: Windows Forms General Synchronise form object event in 2 panels

nobugz

Where's "objform1.Show()" Just use an event handler to duplicate the checked state.





Re: Windows Forms General Synchronise form object event in 2 panels

Am X

Actually i do not want to write event handlers for each and every action in form1, since it contains lot many operations in actual scenario. Instead of creating seperate objects of form1 i want to clone or something, inwhich both the object point to same form1's object. eg.

Form1 objform = new Form1();

objform.TopLevel = false;

//Form1 objform1 = (Form1)objform.Clone();

Form1 objform1 = objform;

panel1.Controls.Add(objform);

objform.Show();

panel2.Controls.Add(objform1);

objform1.Show();

In this case instead of writing code for each event handler, i want to do the operation in second form's object if i do any action in first forms object.

Eg. Check on checkbox in form1(first) should automatically check the checkbox in form1(second)

what has to be done in this scenario.





Re: Windows Forms General Synchronise form object event in 2 panels

nobugz

Controls are far too complicated to allow cloning. You'll need the handlers, no shortcuts.





Re: Windows Forms General Synchronise form object event in 2 panels

Am X

Actually the thing is i am devoloping a windows application, which will be displayed in multiple monitors.

one link for info is http://www.expresscomputeronline.com/20040712/techspace01.shtml

i have one single exe, which will be displayed in 2 monitors for example. In cloning mode (windows display setting) both the screen will display the same content. So there is no issue. (eg. form1 will be displayed in screen1 and screen 2, since both are same, check box click on screen 1 will show check box click on screen2).

Now in my case i want to show 2 different forms of same exe in screen1 and screen 2. (eg. form1 in screen1 and form4 in screen2).

(1) first how do i do that or is there any alternative ways

(2) If i click a check box on form1(screen1), although the screen2 display form4 , the check box on form1 in screen 2 should be checked.

how do i achieve this functionality.

There are actually 2 touch panels connected to the system. And both the touch panels are interactive and shows the same(one main part of the application). In the application for example there are 2 forms in which through one form it controls temperature of the operation room and through other form it controls room light.

But since this is one exe at a time only one operation will happen.(for eg. if an operation in form1 hangs the system(screen1), system will be hanged in screen2 too even it doent show form1)

In extended display, can we show same application, interactive in both the screens in which the screen can show same form or different form

right now i am thinking to create 2 objects on form1 at runtime and attach to the screen boundaries. but how we communicate an event in one object to another object

Or is there any better way by using remoting and all...






Re: Windows Forms General Synchronise form object event in 2 panels

Andreas Johansson

You need to have a place where both forms are instantiated and shown. After the forms are created and shown you need to start the windows message handling.

One way would probably be to change the Program.cs (default name for c# projects) to do

Code Snippet

new Form1().Show();

new Form4().Show();

Application.Run();

This only instantiates and show the forms and you will need to add logic to move them to the proper location (and screen). If you want to communicate between the screens it might be an idea to assign one as the main screen and instantiate and show the "child" screen from the main screen and keep a reference to the child screen. Then you can use the reference to access public properties and methods of the child screen.

There is no restrictions on having one application show two forms and then make them maximized on two separate screens.