Click here to Skip to main content
15,892,927 members
Home / Discussions / C#
   

C#

 
GeneralRe: How can I effectively access the object collection of form1 to another form in WinApp Project? Pin
Aryadip30-May-04 21:48
Aryadip30-May-04 21:48 
GeneralRe: How can I effectively access the object collection of form1 to another form in WinApp Project? Pin
Tuwing.Sabado30-May-04 22:50
Tuwing.Sabado30-May-04 22:50 
GeneralRe: How can I effectively access the object collection of form1 to another form in WinApp Project? Pin
Aryadip31-May-04 2:44
Aryadip31-May-04 2:44 
AnswerRe: How can I effectively access the object collection of form1 to another form in WinApp Project? Pin
partyganger31-May-04 5:26
partyganger31-May-04 5:26 
Generalweb chat! Pin
Silly Boy30-May-04 16:48
Silly Boy30-May-04 16:48 
GeneralRe: web chat! Pin
Wackatronic1-Jun-04 10:05
Wackatronic1-Jun-04 10:05 
GeneralAccessing controls later in code.... Pin
torn8830-May-04 10:45
torn8830-May-04 10:45 
GeneralRe: Accessing controls later in code.... Pin
Peff30-May-04 14:45
Peff30-May-04 14:45 
What I usually do in this type of situation is to give the controls a name that I can rebuild later (much like you do) and create a lookup routine to find them. Doesn't make much sense without an example, huh.

I would name the controls (as I create them) with a name that can be easily parsed from within any event handlers invoked by the control. In keeping with your example,

Panel1 would be named 'tab_1_panel' and would contain
-- tab_1_treeview
-- tab_1_listbox

Panel2 would be named 'tab_2_panel' and would contain
-- tab_2_treeview
-- tab_2_listbox

In this way when an event is fired, I can parse the '1' or '2' out of the name of the invoking control, build the name of the control I need to access and look it up withing the parent's 'control' collection. If the tab_1_treeview fired an event and I needed access to the tab_1_listbox control, I would do the following from the event handler:

Step1 - ParseName
-- string[] sValues = oSender.Name.Split('_'); // returns an array with 3 elements 'tab', '1' and 'treeview'
-- int nIndex = sValues[1];

Step2 - Build listbox name
-- string sName = "tab_" + nIndex.ToString() + "_listbox";

Step3 - Retrieve control from the parent's controls collection
-- ListBox oListbox = this.Parent.Controls[sName];

Let me know if this works for you Smile | :)

GeneralMaking a tray icon Pin
Otis_6930-May-04 10:42
Otis_6930-May-04 10:42 
GeneralRe: Making a tray icon Pin
Nathan Blomquist30-May-04 17:17
Nathan Blomquist30-May-04 17:17 
GeneralRe: Making a tray icon Pin
Otis_6930-May-04 17:39
Otis_6930-May-04 17:39 
GeneralRe: Making a tray icon Pin
Nathan Blomquist30-May-04 18:37
Nathan Blomquist30-May-04 18:37 
Generalhide console window Pin
Otis_6930-May-04 10:40
Otis_6930-May-04 10:40 
GeneralRe: hide console window Pin
Stefan Troschuetz30-May-04 22:18
Stefan Troschuetz30-May-04 22:18 
GeneralRe: hide console window Pin
Otis_6931-May-04 9:33
Otis_6931-May-04 9:33 
GeneralRe: hide console window Pin
Stefan Troschuetz31-May-04 10:33
Stefan Troschuetz31-May-04 10:33 
GeneralRe: hide console window Pin
Otis_6931-May-04 11:43
Otis_6931-May-04 11:43 
GeneralForce termination of a thread Pin
Otis_6930-May-04 10:17
Otis_6930-May-04 10:17 
GeneralRe: Force termination of a thread Pin
Otis_6930-May-04 15:07
Otis_6930-May-04 15:07 
GeneralRe: Force termination of a thread Pin
Otis_6930-May-04 17:41
Otis_6930-May-04 17:41 
GeneralStream to String Pin
Meysam Mahfouzi30-May-04 8:29
Meysam Mahfouzi30-May-04 8:29 
GeneralRe: Stream to String Pin
leppie30-May-04 10:10
leppie30-May-04 10:10 
QuestionHow do I Create Lable Dynamically Pin
Anonymous30-May-04 7:53
Anonymous30-May-04 7:53 
AnswerRe: How do I Create Lable Dynamically Pin
Peff30-May-04 8:30
Peff30-May-04 8:30 
GeneralRemoting with Events Pin
Wouter Van Ranst30-May-04 7:23
Wouter Van Ranst30-May-04 7:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.