Visual Studio - Access PictureBox outside Form1 class?

This is a discussion on Visual Studio - Access PictureBox outside Form1 class? within the C# Programming forums, part of the General Programming Boards category; Ive been trying all day now to get control over a form designer added picturebox from a different class without ...

  1. #1
    Registered User
    Join Date
    Jan 2007
    Posts
    10

    Visual Studio - Access PictureBox outside Form1 class?

    Ive been trying all day now to get control over a form designer added picturebox from a different class without success.

    ive tried from my new class

    Code:
    PictureBox renderWindow = Form1.pictureBox1;
    and i get the following error:

    1 'programnamespace.Form1.pictureBox1' is inaccessible due to its protection level

    2 An object reference is required for the non-static field, method, or property 'programnamespace.Form1.pictureBox1'
    I need to somehow access the pictureBox from outside the class since im going to have both webcam playback ( captureDevice.Render(); ) and video playback ( videoPlayback.Render(); ) and they both need to take control over the designer generated picturebox. Any ideas on how i can span the picturebox over several classes (or) copy the picturebox to each class and have it render in the same place?

    Im running out of ideas, any suggestions?

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    It's generally bad to allow such access, but if you still feel like you must:

    - Enter the form designer
    - Open the properties for the picturebox
    - Change the "Modifiers" property from "Private" to "Public"

    You could also create a (readonly) property to access the picturebox.
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can we have vector of vector?
    By ketu1 in forum C++ Programming
    Replies: 24
    Last Post: 01-03-2008, 04:02 AM
  2. deriving classes
    By l2u in forum C++ Programming
    Replies: 12
    Last Post: 01-15-2007, 04:01 PM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. ras.h errors
    By Trent_Easton in forum Windows Programming
    Replies: 8
    Last Post: 07-15-2005, 10:52 PM
  5. Linking error
    By DockyD in forum C++ Programming
    Replies: 10
    Last Post: 01-20-2003, 04:27 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21