Author Topic: Objects on Multiple Forms (ButtonBar, Titlebar)  (Read 5864 times)

StephenSDH

  • Newbie
  • *
  • Posts: 36
    • View Profile
Objects on Multiple Forms (ButtonBar, Titlebar)
« on: March 30, 2014, 07:50:04 AM »
I have 3 global objects I would like to display on all of the forms.  I'm sure there is a better way then copy/paste.  My guess is I should put the global data to it's own form and display multiple forms at a time.  Does anyone have a recommendation or a sample application?

Thanks,

Steve

hauck7

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: Objects on Multiple Forms (ButtonBar, Titlebar)
« Reply #1 on: December 18, 2014, 11:06:46 PM »
So how did you end up handling this?  Did you go the multiple forms route?

StephenSDH

  • Newbie
  • *
  • Posts: 36
    • View Profile
Re: Objects on Multiple Forms (ButtonBar, Titlebar)
« Reply #2 on: December 18, 2014, 11:31:35 PM »
I ended up copy pasting the objects on each form because I ran out of time and didn't find a better solution. The application was sluggish at first.  I copy pasted only want was needed so I wasn't polling the PLC too hard.  Good luck!

Noe

  • Full Member
  • ***
  • Posts: 205
    • View Profile
Re: Objects on Multiple Forms (ButtonBar, Titlebar)
« Reply #3 on: January 12, 2015, 10:17:30 AM »
I have not had the need to code multiple forms so far, but what I've used is to have multiple controls that do not fit in one form is the tabs. You can put your "general" controls out of the tabs so they will stay the same no mater the selected tab and controls containing it.

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: Objects on Multiple Forms (ButtonBar, Titlebar)
« Reply #4 on: March 11, 2015, 10:54:22 PM »
There is a possible way of doing this by having the Main Form enabled as MDI Parent, set its IsMdiContainer option to True, and displaying all other forms within it as its MDI children forms, use a couple of MenuStrip controls to position buttons and labels and generally pay attention to size and position of the children forms when displayed.

A tutorial with similar idea can be found here:

http://www.codeproject.com/Articles/3553/Introduction-to-MDI-Forms-with-C

See the attached pictures.

Phrog30

  • Guest
Re: Objects on Multiple Forms (ButtonBar, Titlebar)
« Reply #5 on: April 08, 2017, 12:06:02 PM »
I know this thread is old, but I would recommend using a user control for "global objects".  Just understand that the user control will execute in design mode.  So, if that becomes a problem you can add some code to ignore or not allow execution if in design mode:
Code: [Select]
If Not Me.DesignMode Then
'Do something
End If

James