Click here to Skip to main content
15,918,668 members
Home / Discussions / C#
   

C#

 
GeneralRe: Read Excel C# windows form using OleDB Connection Pin
Eddy Vluggen13-Mar-14 3:59
professionalEddy Vluggen13-Mar-14 3:59 
GeneralRe: Read Excel C# windows form using OleDB Connection Pin
OriginalGriff13-Mar-14 4:51
mveOriginalGriff13-Mar-14 4:51 
QuestionCalling through modem to mobile phone Pin
Akshay41112-Mar-14 1:43
Akshay41112-Mar-14 1:43 
AnswerRe: Calling through modem to mobile phone Pin
jschell12-Mar-14 11:14
jschell12-Mar-14 11:14 
QuestionSend info from XNA-game Pin
larsp77711-Mar-14 22:47
larsp77711-Mar-14 22:47 
SuggestionRe: Send info from XNA-game Pin
Richard MacCutchan11-Mar-14 23:01
mveRichard MacCutchan11-Mar-14 23:01 
GeneralRe: Send info from XNA-game Pin
larsp77711-Mar-14 23:29
larsp77711-Mar-14 23:29 
AnswerRe: Send info from XNA-game Pin
Pete O'Hanlon11-Mar-14 23:04
mvePete O'Hanlon11-Mar-14 23:04 
If one of those is responsible for creating the other, don't new up the original one in the new one. So, if Form1 creates Game1, don't do new Form1() in Game1. That will clear your stack overflow.

Now, as to the second part of your problem. There are a few things you could do to get around this. The first method is to pass a reference to Form1 into the1 Game constructor (or explicitly set it at some point before you try to use Game).
C#
public class Game1 : Game
{
  private Form1 form;
  public Game1(Form1 form)
  {
    this.form = form;
  }
}

public class Form1 : Form
{
  private Game1 game;
  public Form1()
  {
    game = new Game1(this);
  }
}
The other way to do this, and the way I tend to prefer, is to use events in Game1 to signal that Form1 should do something. By using events, you decouple Game1 from having to know anything at all about Form1 - which means you could swap it into other projects far easier. Basically, after you instantiate Game1 in Form1, you can subscribe to the events that you're interested in and use those as appropriate.
GeneralRe: Send info from XNA-game Pin
larsp77711-Mar-14 23:30
larsp77711-Mar-14 23:30 
GeneralRe: Send info from XNA-game Pin
Pete O'Hanlon11-Mar-14 23:35
mvePete O'Hanlon11-Mar-14 23:35 
QuestionChart Control Pin
Subin Mavunkal11-Mar-14 21:39
Subin Mavunkal11-Mar-14 21:39 
AnswerRe: Chart Control Pin
Richard MacCutchan11-Mar-14 22:59
mveRichard MacCutchan11-Mar-14 22:59 
AnswerRe: Chart Control Pin
BillWoodruff12-Mar-14 18:29
professionalBillWoodruff12-Mar-14 18:29 
QuestionHow to display many terminal in other server software ? Pin
Ramkrishn Mishra11-Mar-14 21:15
Ramkrishn Mishra11-Mar-14 21:15 
AnswerRe: How to display many terminal in other server software ? Pin
Richard MacCutchan11-Mar-14 22:58
mveRichard MacCutchan11-Mar-14 22:58 
AnswerRe: How to display many terminal in other server software ? Pin
OriginalGriff11-Mar-14 23:28
mveOriginalGriff11-Mar-14 23:28 
QuestionCOPY ACCESS TABLE FROM ONE DATABASE TO OTHER Pin
pelitech11-Mar-14 18:47
pelitech11-Mar-14 18:47 
AnswerRe: COPY ACCESS TABLE FROM ONE DATABASE TO OTHER Pin
Chris Quinn11-Mar-14 21:57
Chris Quinn11-Mar-14 21:57 
AnswerRe: COPY ACCESS TABLE FROM ONE DATABASE TO OTHER Pin
OriginalGriff11-Mar-14 22:12
mveOriginalGriff11-Mar-14 22:12 
GeneralRe: COPY ACCESS TABLE FROM ONE DATABASE TO OTHER Pin
harold aptroot11-Mar-14 23:32
harold aptroot11-Mar-14 23:32 
QuestionC# technology Pin
Member 1066255811-Mar-14 15:17
Member 1066255811-Mar-14 15:17 
AnswerRe: C# technology Pin
Dave Kreskowiak11-Mar-14 15:39
mveDave Kreskowiak11-Mar-14 15:39 
AnswerRe: C# technology Pin
Peter Leow11-Mar-14 16:11
professionalPeter Leow11-Mar-14 16:11 
AnswerRe: C# technology Pin
BillWoodruff11-Mar-14 19:05
professionalBillWoodruff11-Mar-14 19:05 
AnswerRe: C# technology Pin
thatraja11-Mar-14 22:10
professionalthatraja11-Mar-14 22:10 

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.