Click here to Skip to main content
15,887,027 members
Home / Discussions / C#
   

C#

 
GeneralRe: Debugger issues Pin
Mustafa Ismail Mustafa28-Dec-08 3:32
Mustafa Ismail Mustafa28-Dec-08 3:32 
AnswerRe: Debugger issues Pin
Guffa28-Dec-08 7:20
Guffa28-Dec-08 7:20 
GeneralRe: Debugger issues Pin
Mustafa Ismail Mustafa28-Dec-08 9:17
Mustafa Ismail Mustafa28-Dec-08 9:17 
GeneralRe: Debugger issues Pin
Guffa28-Dec-08 14:21
Guffa28-Dec-08 14:21 
GeneralRe: Debugger issues Pin
Luc Pattyn28-Dec-08 14:29
sitebuilderLuc Pattyn28-Dec-08 14:29 
Questionuser control interaction Pin
dustybike28-Dec-08 1:54
dustybike28-Dec-08 1:54 
AnswerRe: user control interaction Pin
Colin Angus Mackay28-Dec-08 3:53
Colin Angus Mackay28-Dec-08 3:53 
AnswerRe: user control interaction Pin
Code Soldier28-Dec-08 4:21
Code Soldier28-Dec-08 4:21 
The child knowing about the parent is the simplest way though. Make a global variable that points to the parent form, or pass a variable pointing to the parent form into the user control and invoke methods on the parent. There is a point to having user controls in this case, both for code encapsulation/organization, or if the parent needed more than one of these children and each had their own index.

class Form1 : Form
 {
     public Form1()
     {
                  Form2 form2 = new Form2( this );
     }
 }


The event way mentioned is a little trickier but not much. Make a public event inside Form2.

public delegate void MyDelegate(object owner, EventArgs args);
public event MyDelegate myEvent;

private void OnEvent(object owner, EventArgs args)
           {
           object[] argsArray = new object[2];

           argsArray[0] = owner;
           argsArray[1] = args;

           this.BeginInvoke( myEvent, argsArray );
            }



Now anyone can subscribe to myEvent and call their own event handler.

Use interfaces if you prefer the abstraction of prgramming to interfaces. Some people consider this the most reusable code.
GeneralRe: user control interaction Pin
Colin Angus Mackay28-Dec-08 6:58
Colin Angus Mackay28-Dec-08 6:58 
QuestionProblem with a byte array buffer Pin
ajorge200828-Dec-08 1:43
ajorge200828-Dec-08 1:43 
AnswerRe: Problem with a byte array buffer Pin
Richard Andrew x6428-Dec-08 3:00
professionalRichard Andrew x6428-Dec-08 3:00 
GeneralRe: Problem with a byte array buffer Pin
ajorge200828-Dec-08 3:23
ajorge200828-Dec-08 3:23 
GeneralRe: Problem with a byte array buffer Pin
Luc Pattyn28-Dec-08 14:35
sitebuilderLuc Pattyn28-Dec-08 14:35 
AnswerRe: Problem with a byte array buffer Pin
Wendelius28-Dec-08 12:02
mentorWendelius28-Dec-08 12:02 
GeneralRe: Problem with a byte array buffer Pin
ajorge200828-Dec-08 22:33
ajorge200828-Dec-08 22:33 
GeneralRe: Problem with a byte array buffer Pin
ajorge200829-Dec-08 0:32
ajorge200829-Dec-08 0:32 
GeneralRe: Problem with a byte array buffer Pin
ajorge200829-Dec-08 6:13
ajorge200829-Dec-08 6:13 
QuestionShowing multiple forms inside a single form Pin
shaf21127-Dec-08 23:19
shaf21127-Dec-08 23:19 
AnswerRe: Showing multiple forms inside a single form Pin
#realJSOP27-Dec-08 23:50
mve#realJSOP27-Dec-08 23:50 
GeneralRe: Showing multiple forms inside a single form Pin
shaf21129-Dec-08 22:18
shaf21129-Dec-08 22:18 
AnswerRe: Showing multiple forms inside a single form Pin
Code Soldier28-Dec-08 4:47
Code Soldier28-Dec-08 4:47 
GeneralRe: Showing multiple forms inside a single form Pin
shaf21129-Dec-08 22:22
shaf21129-Dec-08 22:22 
QuestionActiveX PDF problem Pin
frappydan27-Dec-08 23:10
frappydan27-Dec-08 23:10 
QuestionVPN programmin Pin
sepel27-Dec-08 23:01
sepel27-Dec-08 23:01 
QuestionPython to .Net tool Pin
George_George27-Dec-08 21:20
George_George27-Dec-08 21:20 

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.