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 get an object's values from other form ?

how to get an object's values from other form ?

Scheduled Pinned Locked Moved C#
questioncsharptutorial
2 Posts 2 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.
  • P Offline
    P Offline
    pkBob
    wrote on last edited by
    #1

    Hi. im am a newbie with c#. i had created an object in one form (e.g. Form1) and i need its values from Form2. i also need the possibility to change my object's values from Form2. how do i do that ??? Thank .... Bob.:omg:

    D 1 Reply Last reply
    0
    • P pkBob

      Hi. im am a newbie with c#. i had created an object in one form (e.g. Form1) and i need its values from Form2. i also need the possibility to change my object's values from Form2. how do i do that ??? Thank .... Bob.:omg:

      D Offline
      D Offline
      draco_iii
      wrote on last edited by
      #2

      That would depend entirely on exactly what you are trying to do. If the Object is a Control you have added to the form and you know the objects name. You can access the Controls properties and methods viafor(int i = 0; i == this.ParentForm.Controls.Count-1;i += 1){ //Perform actions on registered objects. if(this.ParentForm.Controls[i].Name == "ControlName"){ //Perform actions on control. } }
      However, if you need to access varibles only, you should create a static class similar to this.using System; namespace staticTest { public class Setting{ public static String[] test = new String[10]; public static int[] testInt = new int[10]; static Setting(){ } } }

      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