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. Referencing a textBox on a tabControl

Referencing a textBox on a tabControl

Scheduled Pinned Locked Moved C#
csharp
4 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.
  • T Offline
    T Offline
    TCHamilton
    wrote on last edited by
    #1

    I have a form with a tabControl with two pages. On the second tab page is a textbox(txtMLBox_ID). I need to reference it from a module in another part of the application but can't seem to get the reference syntax correct. Namespace: LabelTool Form: MainForm (also in LabelTool ns) tabControl: tabControl1 tabPage: tabMultiRuncard textbox: txtMLBox Attempting to access from: MultiLotRC.cs which is also in the LabelTool ns I thought that MainForm.tabControl1.txtMLBox.ToString() would work but I'm pretty rummy from trying every purmutation I can think of. This probably is not a difficult as I'm making it. Progamming in C# (vs2005) TIA

    Tom Hamilton

    E 1 Reply Last reply
    0
    • T TCHamilton

      I have a form with a tabControl with two pages. On the second tab page is a textbox(txtMLBox_ID). I need to reference it from a module in another part of the application but can't seem to get the reference syntax correct. Namespace: LabelTool Form: MainForm (also in LabelTool ns) tabControl: tabControl1 tabPage: tabMultiRuncard textbox: txtMLBox Attempting to access from: MultiLotRC.cs which is also in the LabelTool ns I thought that MainForm.tabControl1.txtMLBox.ToString() would work but I'm pretty rummy from trying every purmutation I can think of. This probably is not a difficult as I'm making it. Progamming in C# (vs2005) TIA

      Tom Hamilton

      E Offline
      E Offline
      Edbert P
      wrote on last edited by
      #2

      I believe the controls generated by the designer is marked as private, which means if you want to access it from somewhere else you need to create a property that returns your control.

      "A democracy is nothing more than mob rule, where fifty-one percent of the people may take away the rights of the other forty-nine." - Thomas Jefferson "Democracy is two wolves and a lamb voting on what to have for lunch. Liberty is a well-armed lamb contesting the vote." - Benjamin Franklin Edbert Sydney, Australia

      T 1 Reply Last reply
      0
      • E Edbert P

        I believe the controls generated by the designer is marked as private, which means if you want to access it from somewhere else you need to create a property that returns your control.

        "A democracy is nothing more than mob rule, where fifty-one percent of the people may take away the rights of the other forty-nine." - Thomas Jefferson "Democracy is two wolves and a lamb voting on what to have for lunch. Liberty is a well-armed lamb contesting the vote." - Benjamin Franklin Edbert Sydney, Australia

        T Offline
        T Offline
        TCHamilton
        wrote on last edited by
        #3

        Thank you Edbert, (I'm very new to Object Oriented) Are you suggesting I do the get/set for a property then reference it?

        Tom Hamilton

        E 1 Reply Last reply
        0
        • T TCHamilton

          Thank you Edbert, (I'm very new to Object Oriented) Are you suggesting I do the get/set for a property then reference it?

          Tom Hamilton

          E Offline
          E Offline
          Edbert P
          wrote on last edited by
          #4

          Yep. Do a get property (I don't think you need to create a set property) in order to be able to access the control within the form. Otherwise you can also change the control's Modifiers through the form designer from private to public. Hope that helps. :)

          "A democracy is nothing more than mob rule, where fifty-one percent of the people may take away the rights of the other forty-nine." - Thomas Jefferson "Democracy is two wolves and a lamb voting on what to have for lunch. Liberty is a well-armed lamb contesting the vote." - Benjamin Franklin Edbert Sydney, Australia

          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