Am developing a two screen application where first screen resides in the user system and other screen in extended mode is directed towards a projector or another monitor. They all are working perfectly. Now my client asked me if I can preview the secondary screen onto the primary screen. I tried to display the form inside a group box using:

Dim f1 As New Form2
f1.TopLevel = False
f1.Visible = True
groupBox1.Controls.Add(f1)

and successfully displayed the form. But the problem is that whenever I make changes in the Form2 from main form, I couldn't update the form f1. I tried to place the above code inside a timer control. But the original form keeps on flickering every second (as time interval is set to 1000) and now I couldn't access the main form.

Then I tried to place the code inside a datagridview_selectionChanged event and added

groupbox1.controls.clear()

but still the f1 does not update with the form2.

I am stuck here and couldn't find a way to preview a second form inside a first form. Is there any alternative?

Recommended Answers

All 3 Replies

It appears that you are creating a new instance of Form2 which is why your data is not updated. What do you consider a "Preview". A copy of the form that can be modified? Or an image of the form that one can look at? If you are looking to provide an image, look up "screen capture" and/or "window capture". If you want to use a new instance of your form, look at the tutorial on form to form communication. You could create your other instance of Form2 (previewFrm2) : Private previewFrm2 as New Form2. Change the "Modifiers" on Form2 to public. When you receive the data updates on the main form, you can set the values on previewFrm2 to the same values (previewFrm2.TextBox1.Text = "new text value")

Your second method is tougher since, There are around 50 controls in that secondary form, so if I set the values for each of the controls again for the instance, the code is not an optimized one.

"Preview" in the sense I mean something like power point (presenter view), the secondary screen is visible in primary screen. Similarly, I pass some data to be displayed in secondary form from the primary form. And the secondary screen maynot be visible to operator, so I wanted the secondary screen to be displayed at a corner of a primary screen, in a group box.

I don't mind if it is an image or a screen capture or a form instance. I just need the secondary form to be displayed inside my primary form's group box.

Your second method is tougher since, There are around 50 controls in that secondary form, so if I set the values for each of the controls again for the instance, the code is not an optimized one.

"Preview" in the sense I mean something like power point (presenter view), the secondary screen is visible in primary screen. Similarly, I pass some data to be displayed in secondary form from the primary form. And the secondary screen maynot be visible to operator, so I wanted the secondary screen to be displayed at a corner of a primary screen, in a group box.

I don't mind if it is an image or a screen capture or a form instance. I just need the secondary form to be displayed inside my primary form's group box.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.