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