Access Controls, Tab Controls, User Controls, C#, Windows forms
Posted on 2010-01-11
Let me explain the windows application,
">" symbol stands for Contains [Eg. Form > Main Tab Control ... Form Contains Main Tab Control]
I have - Form1 > Main Tab Control > Main Tab Page > User Control > Sub Tab Control > Sub Tab Page > User Control > Contols/Text Box.
Form - The main form
Main Tab Control - This contains Main Tab Pages.
Main Tab Pages - Each Tap Page is a separate file. Each Main Tap Page contains a User Control which has a Sub Tab Control.
Sub Tab Control - This contains various Tab Pages [Lets say TabOne, TabTwo, TabThree]. Only the TabOne is different for each Main Tab Page.
Sub Tab Pages - Have various controls - Text Boxes, Buttons etc.
I can create the GUI and it works great. But I want a way to access Controls in the Sub Tab Pages keeping in mind what file is open[Tab Pages in the the Main Tab Control]
Lets say I have a File Save Event from the Main Menu Bar, I need only the contents of the active file to be saved. Simplest form like a webbrowser, when you save the page, only the page in the
active tab is saved. In my case of course I need to keep track of the Main Tab Control active tab and the Sub Tab Control active tab.
How do I keep track of it?
In the most simplest form, to get an idea - Create a Tab Control with a tab page [TP1] . Embed a another User Cntrl which contains a Sub Tab Control in TP1. The Sub Tab Control has tap pages [STP1,
STP2]. STP1 has some text boxes, other controls. Now duplicate TP1 thru an event [New file event] so that there is TP1, TP2, TP3, ....Now lets say we fire an external event [Like File Save, File
Save As evenst from Main Menu], how do I keep track of the values in textboxes/controls wrt to what Main Tab Page is open.
Should I be following a different approach? What is the best programming practice?
Also what is the best way to communicate values and parameters between different User Controls.
I`m using C#, VS 2008
Ideas are welcome!