Click here to Skip to main content
15,913,941 members
Home / Discussions / C#
   

C#

 
AnswerRe: can silverlight and c# work together? Pin
Christian Graus7-May-07 13:04
protectorChristian Graus7-May-07 13:04 
QuestionBindingSource.Filter problem Pin
Seishin#7-May-07 11:28
Seishin#7-May-07 11:28 
AnswerRe: BindingSource.Filter problem Pin
Anil Ch7-May-07 12:02
Anil Ch7-May-07 12:02 
Questionhow to use TreeView control for show Hierarchy data ? Pin
hdv2127-May-07 11:02
hdv2127-May-07 11:02 
AnswerRe: how to use TreeView control for show Hierarchy data ? Pin
PIEBALDconsult7-May-07 16:35
mvePIEBALDconsult7-May-07 16:35 
QuestionEvent Exception Pin
Justin Perez7-May-07 10:02
Justin Perez7-May-07 10:02 
AnswerRe: Event Exception Pin
Colin Angus Mackay7-May-07 10:19
Colin Angus Mackay7-May-07 10:19 
AnswerRe: Event Exception Pin
bearfx7-May-07 10:31
bearfx7-May-07 10:31 
Is anything actually assigned to handle the OnImportFile?

someObject.OnImportFile+= new OnImportFileEvent(someHandler);

If not, you will get an exception Take this example code
<br />
 class Program {<br />
        static void Main(string[] args) {<br />
            someClass obj = new someClass();<br />
            //Exception Here<br />
            obj.RaiseEvent();<br />
            obj.someEvent += new someClass.SomeEvent(EventHandler);<br />
            //No Exception<br />
            obj.RaiseEvent();<br />
        }<br />
        static void EventHandler(object sender, EventArgs e) {<br />
            <br />
        }<br />
    }<br />
    class someClass {<br />
        public delegate void SomeEvent(object sender, EventArgs args);<br />
<br />
        public  SomeEvent someEvent;<br />
<br />
        public void RaiseEvent() {<br />
            someEvent(this,new EventArgs());<br />
        }<br />
    }


You can resolve this by testing someEvent for null
<br />
public void RaiseEvent() {<br />
   if(someEvent!=null)<br />
     someEvent(this,new EventArgs());<br />
}<br />



or setting it to have at least one handler when you create the object
<br />
    class someClass {<br />
        public delegate void SomeEvent(object sender, EventArgs args);<br />
         <br />
        public  SomeEvent someEvent;<br />
        someClass{<br />
              someEvent+=new SomeEvent(internalHandler);<br />
        }<br />
        private void internalHandler(object sender, EventArgs e) {}<br />
        public void RaiseEvent() {<br />
            someEvent(this,new EventArgs());<br />
        }<br />
    }


I usually test for null, but either works.
GeneralRe: Event Exception Pin
Justin Perez8-May-07 7:19
Justin Perez8-May-07 7:19 
Questiondisable next button Pin
FernandoMartin7-May-07 7:54
FernandoMartin7-May-07 7:54 
AnswerRe: disable next button Pin
Giorgi Dalakishvili7-May-07 8:03
mentorGiorgi Dalakishvili7-May-07 8:03 
GeneralRe: disable next button Pin
FernandoMartin7-May-07 8:11
FernandoMartin7-May-07 8:11 
GeneralRe: disable next button Pin
Giorgi Dalakishvili7-May-07 8:16
mentorGiorgi Dalakishvili7-May-07 8:16 
Questionincorrect sorting in dataGridView Pin
KLASTER7-May-07 7:52
KLASTER7-May-07 7:52 
AnswerRe: incorrect sorting in dataGridView Pin
Anil Ch7-May-07 12:11
Anil Ch7-May-07 12:11 
QuestionCan I have the same functionality on my Windows Application as I have on my DataBase Server? Pin
Khoramdin7-May-07 7:50
Khoramdin7-May-07 7:50 
AnswerRe: Can I have the same functionality on my Windows Application as I have on my DataBase Server? Pin
Salogus7-May-07 19:04
Salogus7-May-07 19:04 
QuestionAnt on a Chessboard Pin
M.omar7-May-07 7:45
M.omar7-May-07 7:45 
AnswerRe: Ant on a Chessboard Pin
Dave Kreskowiak7-May-07 7:55
mveDave Kreskowiak7-May-07 7:55 
AnswerRe: Ant on a Chessboard Pin
mav.northwind7-May-07 7:57
mav.northwind7-May-07 7:57 
GeneralRe: Ant on a Chessboard Pin
Blumen7-May-07 18:47
Blumen7-May-07 18:47 
AnswerRe: Ant on a Chessboard Pin
led mike7-May-07 8:20
led mike7-May-07 8:20 
AnswerRe: Ant on a Chessboard Pin
PIEBALDconsult7-May-07 17:36
mvePIEBALDconsult7-May-07 17:36 
QuestionScrolling background in C# Winform?? Pin
llonden2kx7-May-07 7:14
llonden2kx7-May-07 7:14 
AnswerRe: Scrolling background in C# Winform?? Pin
Dave Kreskowiak7-May-07 7:27
mveDave Kreskowiak7-May-07 7:27 

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.