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. access public controls on form2 from form1

access public controls on form2 from form1

Scheduled Pinned Locked Moved C#
question
2 Posts 2 Posters 14 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.
  • C Offline
    C Offline
    Carlos Lopes
    wrote on last edited by
    #1

    Hi, on my app, i've 2 forms (form1 and form2). On form2 i've dropped a combobox (named cb1) and declared it has public( public System.Windows.Forms.ComboBox cb1;). Now, i want to access it from form1 (whit a statment like this one: Form f2 = new form2(); f2.cb1.size.With = 30;) , but i do not have access to it...???? What do i need to do to see my form2 combobox from form1, i thought that it would bee enough to declare it public, but looks like i'm wrong... Thanks Carlos Lopes

    L 1 Reply Last reply
    0
    • C Carlos Lopes

      Hi, on my app, i've 2 forms (form1 and form2). On form2 i've dropped a combobox (named cb1) and declared it has public( public System.Windows.Forms.ComboBox cb1;). Now, i want to access it from form1 (whit a statment like this one: Form f2 = new form2(); f2.cb1.size.With = 30;) , but i do not have access to it...???? What do i need to do to see my form2 combobox from form1, i thought that it would bee enough to declare it public, but looks like i'm wrong... Thanks Carlos Lopes

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      You'll have to make that combobox a property (read-only).

      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