Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to access from objects from other class

How to access from objects from other class

Scheduled Pinned Locked Moved C#
tutorial
5 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    signimage
    wrote on last edited by
    #1

    In form i have different object (like picturebox),i want to acces these object from another class for example class1

    C Q M M 4 Replies Last reply
    0
    • S signimage

      In form i have different object (like picturebox),i want to acces these object from another class for example class1

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      This is essentially the same question you asked before[^] and the results will be the same because the object you are trying to access is not instantiated because you are not fully instantiating the form the object comes from. So far you have not told us the overall goal of your application is, of even this part of the application. I think that there is a better way to do what you are trying to do because from the description you have supplied so far I cannot invisage that the application is designed very well.


      *** Developer Day 4 in Reading, England on 2nd December 2006 - Registration Now Open *** Upcoming Scottish Developers events: * Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog

      1 Reply Last reply
      0
      • S signimage

        In form i have different object (like picturebox),i want to acces these object from another class for example class1

        Q Offline
        Q Offline
        quiteSmart
        wrote on last edited by
        #3

        Accessing an object properties or methods from another form is unallowed in a direct way. This is because when the compiler creates those objects, they are declared as private so u can not access it from outside the scope where it is created. u can pass over this in one solution, this is by definning some public function in that form tha do the actions u need in the properties of those objects. And u should pass a reference of the first form to the second form through the constructor of the second form. hope it helps. best regards Jamil Abou Khalil

        1 Reply Last reply
        0
        • S signimage

          In form i have different object (like picturebox),i want to acces these object from another class for example class1

          M Offline
          M Offline
          Mairaaj Khan
          wrote on last edited by
          #4

          signimage wrote:

          In form i have different object (like picturebox),i want to acces these object from another class for example class1

          The default access/visibility level of the form's objects is private. To use your form's objects in another class, you have to change its access level from private to public (or what is more appropriate) through its Modifiers property.

          ________________________________ Success is not something to wait for, its something to work for.

          1 Reply Last reply
          0
          • S signimage

            In form i have different object (like picturebox),i want to acces these object from another class for example class1

            M Offline
            M Offline
            mohammadSoft
            wrote on last edited by
            #5

            you should declare object public in partial class and formName.objectName acces object .

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups