Click here to Skip to main content
15,891,184 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to reuse event Pin
lukeer15-Apr-14 20:54
lukeer15-Apr-14 20:54 
GeneralRe: How to reuse event Pin
Dave Kreskowiak16-Apr-14 1:26
mveDave Kreskowiak16-Apr-14 1:26 
GeneralRe: How to reuse event Pin
Member 1034709216-Apr-14 1:08
Member 1034709216-Apr-14 1:08 
GeneralRe: How to reuse event Pin
Dave Kreskowiak16-Apr-14 1:27
mveDave Kreskowiak16-Apr-14 1:27 
GeneralRe: How to reuse event Pin
Member 1034709216-Apr-14 4:21
Member 1034709216-Apr-14 4:21 
QuestionC# use all controls on different form Pin
t..bdiesel14-Apr-14 2:35
t..bdiesel14-Apr-14 2:35 
AnswerRe: C# use all controls on different form Pin
joost.versteegen14-Apr-14 20:42
joost.versteegen14-Apr-14 20:42 
GeneralRe: C# use all controls on different form Pin
t..bdiesel15-Apr-14 3:56
t..bdiesel15-Apr-14 3:56 
Joost thanks for this solution.

You should reply in the forum, so other people can learn or perticipate. If you instantiate your forms with the button from the Map editor you can pass a reference to the map editor and then you do not need a static method. Like the following (Form1 is the map editor and Form2 is a "form with a button"):


public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();

Form2 f = new Form2(foo);
f.Show();
}

public void foo(object sender, EventArgs e)
{
MessageBox.Show("foo");
this.Text = "I was foo-ed";
}
}

public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}

public Form2(EventHandler h)
{
InitializeComponent();
this.button1.Click += h;
}
}

Another approach is the following:


public partial class Form1 : Form
{
public static EventHandler fooHandler;

public Form1()
{
InitializeComponent();
fooHandler = foo;

Form2 f = new Form2();
f.Show();
}

public void foo(object sender, EventArgs e)
{
MessageBox.Show("foo");
this.Text = "I was foo-ed";
}
}
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
this.button1.Click += Form1.fooHandler;
}
}
it works lik this
GeneralRe: C# use all controls on different form Pin
t..bdiesel15-Apr-14 4:02
t..bdiesel15-Apr-14 4:02 
GeneralRe: C# use all controls on different form Pin
joost.versteegen15-Apr-14 4:48
joost.versteegen15-Apr-14 4:48 
GeneralRe: C# use all controls on different form Pin
t..bdiesel15-Apr-14 21:20
t..bdiesel15-Apr-14 21:20 
QuestionCrystal Report 2008 export to text problem Pin
Member 1073816613-Apr-14 22:10
Member 1073816613-Apr-14 22:10 
AnswerRe: Crystal Report 2008 export to text problem Pin
Maciej Los13-Apr-14 23:08
mveMaciej Los13-Apr-14 23:08 
GeneralRe: Crystal Report 2008 export to text problem Pin
Member 1073816615-Apr-14 1:01
Member 1073816615-Apr-14 1:01 
GeneralRe: Crystal Report 2008 export to text problem Pin
Maciej Los23-Apr-14 1:18
mveMaciej Los23-Apr-14 1:18 
Questionhow to solve- when windows forms application exe run from program files then it getting very slow Pin
Member 1029340813-Apr-14 20:47
professionalMember 1029340813-Apr-14 20:47 
AnswerRe: how to solve- when windows forms application exe run from program files then it getting very slow Pin
Sivaraman Dhamodharan13-Apr-14 20:56
Sivaraman Dhamodharan13-Apr-14 20:56 
GeneralRe: how to solve- when windows forms application exe run from program files then it getting very slow Pin
Member 1029340813-Apr-14 23:38
professionalMember 1029340813-Apr-14 23:38 
GeneralRe: how to solve- when windows forms application exe run from program files then it getting very slow Pin
Sivaraman Dhamodharan14-Apr-14 2:41
Sivaraman Dhamodharan14-Apr-14 2:41 
AnswerRe: how to solve- when windows forms application exe run from program files then it getting very slow Pin
Richard MacCutchan13-Apr-14 22:04
mveRichard MacCutchan13-Apr-14 22:04 
AnswerRe: how to solve- when windows forms application exe run from program files then it getting very slow Pin
Dave Kreskowiak14-Apr-14 1:23
mveDave Kreskowiak14-Apr-14 1:23 
QuestionWhy is it allowed to create public constructor of an abstract class in C# ? Pin
Varun Thakur13-Apr-14 18:54
Varun Thakur13-Apr-14 18:54 
AnswerRe: Why is it allowed to create public constructor of an abstract class in C# ? Pin
OriginalGriff13-Apr-14 22:02
mveOriginalGriff13-Apr-14 22:02 
AnswerRe: Why is it allowed to create public constructor of an abstract class in C# ? Pin
Eddy Vluggen13-Apr-14 22:32
professionalEddy Vluggen13-Apr-14 22:32 
QuestionClear a tab contents when i switch tabs Pin
alfie.max1513-Apr-14 5:29
alfie.max1513-Apr-14 5:29 

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.