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

C#

 
AnswerRe: Compare Images "before and after" Pin
Eddy Vluggen16-Jul-12 23:13
professionalEddy Vluggen16-Jul-12 23:13 
GeneralRe: Compare Images "before and after" Pin
ToBick17-Jul-12 4:47
ToBick17-Jul-12 4:47 
GeneralRe: Compare Images "before and after" Pin
Eddy Vluggen17-Jul-12 4:53
professionalEddy Vluggen17-Jul-12 4:53 
GeneralRe: Compare Images "before and after" Pin
ToBick17-Jul-12 6:57
ToBick17-Jul-12 6:57 
AnswerRe: Compare Images "before and after" Pin
Eddy Vluggen17-Jul-12 7:52
professionalEddy Vluggen17-Jul-12 7:52 
GeneralRe: Compare Images "before and after" Pin
Pete O'Hanlon17-Jul-12 8:23
mvePete O'Hanlon17-Jul-12 8:23 
AnswerRe: Compare Images "before and after" Pin
Abhinav S16-Jul-12 23:15
Abhinav S16-Jul-12 23:15 
QuestionReturning Instance Issue - Object Reference Not Set Pin
AmbiguousName16-Jul-12 22:00
AmbiguousName16-Jul-12 22:00 
Hello there. I have a class which is designed to have only one instance. I instantiate this class in the main dialog. Then in one of my tabs, I try to get this class' object but it stated

Object reference not set to an Instance of an object

Here is what I am trying to far.
public class SingleClass  // designed to have one object only
{
  public SingleClass SingleObj {get;set;} 
  public MainDlg MainDlgObj {get;set;}

  public SingleClass(ref MainDlg main)
  {
    SingleObj = this;
    MainDlgObj = main;
  }
}

public class MainDlg
{
  SingleClass sc;
  public MainDlg()
  {
    var MainDlgObj = this;
    sc = new SingleClass(ref MainDlgObj);  // Instantiating SinegleClass here
  }

  public void ShowMessage()
  {
    MessageBox.Show("Hello From MainDlg");
  }
}

Now in one of my tabs in this main dialog, I am trying to call this ShowMessage() method via SingleClass like this but it gives the said error
public class Tab1
{
  SingleClass sc;
  public void Function_InTab()
  {
    // here i want ShowMessage in MainDlg
    sc.SingleObj.MainDlgObj.ShowMessage();
  }
}

The code compiles well but it fails at runtime with the said error. How can I show ShowMessage() here? Thanks for any input.

This world is going to explode due to international politics, SOON.

AnswerRe: Returning Instance Issue - Object Reference Not Set Pin
Pete O'Hanlon16-Jul-12 22:16
mvePete O'Hanlon16-Jul-12 22:16 
QuestionRe: Returning Instance Issue - Object Reference Not Set Pin
Eddy Vluggen16-Jul-12 23:16
professionalEddy Vluggen16-Jul-12 23:16 
AnswerRe: Returning Instance Issue - Object Reference Not Set Pin
AmbiguousName16-Jul-12 23:25
AmbiguousName16-Jul-12 23:25 
QuestionRe: Returning Instance Issue - Object Reference Not Set Pin
Eddy Vluggen16-Jul-12 23:30
professionalEddy Vluggen16-Jul-12 23:30 
AnswerRe: Returning Instance Issue - Object Reference Not Set Pin
AmbiguousName16-Jul-12 23:37
AmbiguousName16-Jul-12 23:37 
AnswerRe: Returning Instance Issue - Object Reference Not Set Pin
Eddy Vluggen16-Jul-12 23:52
professionalEddy Vluggen16-Jul-12 23:52 
AnswerRe: Returning Instance Issue - Object Reference Not Set Pin
DaveyM6917-Jul-12 1:46
professionalDaveyM6917-Jul-12 1:46 
AnswerRe: Returning Instance Issue - Object Reference Not Set Pin
AmbiguousName17-Jul-12 20:02
AmbiguousName17-Jul-12 20:02 
GeneralRe: Returning Instance Issue - Object Reference Not Set Pin
BobJanova17-Jul-12 4:01
BobJanova17-Jul-12 4:01 
GeneralRe: Returning Instance Issue - Object Reference Not Set Pin
DaveyM6917-Jul-12 10:31
professionalDaveyM6917-Jul-12 10:31 
GeneralRe: Returning Instance Issue - Object Reference Not Set Pin
BobJanova18-Jul-12 2:26
BobJanova18-Jul-12 2:26 
GeneralRe: Returning Instance Issue - Object Reference Not Set Pin
DaveyM6918-Jul-12 4:52
professionalDaveyM6918-Jul-12 4:52 
GeneralRe: Returning Instance Issue - Object Reference Not Set Pin
BobJanova18-Jul-12 6:31
BobJanova18-Jul-12 6:31 
GeneralRe: Returning Instance Issue - Object Reference Not Set Pin
BobJanova17-Jul-12 4:05
BobJanova17-Jul-12 4:05 
GeneralRe: Returning Instance Issue - Object Reference Not Set Pin
Matt T Heffron17-Jul-12 8:07
professionalMatt T Heffron17-Jul-12 8:07 
GeneralRe: Returning Instance Issue - Object Reference Not Set Pin
BobJanova18-Jul-12 2:19
BobJanova18-Jul-12 2:19 
GeneralRe: Returning Instance Issue - Object Reference Not Set Pin
Matt T Heffron24-Jul-12 8:04
professionalMatt T Heffron24-Jul-12 8:04 

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.