Click here to Skip to main content
15,926,507 members
Home / Discussions / C#
   

C#

 
GeneralRe: How can I programm the inner representation of a decimal number? Pin
HilSoft27-Jul-06 8:33
HilSoft27-Jul-06 8:33 
GeneralRe: How can I programm the inner representation of a decimal number? Pin
Dan Neely27-Jul-06 8:40
Dan Neely27-Jul-06 8:40 
GeneralRe: How can I programm the inner representation of a decimal number? Pin
HilSoft27-Jul-06 8:47
HilSoft27-Jul-06 8:47 
GeneralRe: How can I programm the inner representation of a decimal number? Pin
Dan Neely27-Jul-06 9:31
Dan Neely27-Jul-06 9:31 
GeneralRe: How can I programm the inner representation of a decimal number? [modified] Pin
HilSoft27-Jul-06 10:04
HilSoft27-Jul-06 10:04 
AnswerRe: How can I programm the inner representation of a decimal number? Pin
Not Active27-Jul-06 8:15
mentorNot Active27-Jul-06 8:15 
GeneralRe: How can I programm the inner representation of a decimal number? Pin
HilSoft27-Jul-06 8:52
HilSoft27-Jul-06 8:52 
QuestionDelegates Pin
~~~Johnny~~~27-Jul-06 6:55
~~~Johnny~~~27-Jul-06 6:55 
I am new in C# and nobody could clarify this:

Yesterday I created some kind of an observer pattern

I created a delegate and two combo boxes, in one I set an event for changes using the delegate and in the other one I "listen" to that event. This works great, whenever the cahnge occurs in the first combo, the second one adjusts itself accordingly. The problem is if I didn't set a listener yet I get a null object exception for the line where I fire the event. Is this normal or am I doing something wrong ? To solve the problem I verify first if the object is null but I want to be sure I am not doing something stupid

Here is the code (useless lines removed)

public class CountryCombo : ComboBox
{
public event CountryChangedHandler countryChanged;
...code

public CountryCombo() : base()
{
...code
this.Leave += new EventHandler(CountryCombo_Leave);
this.BindingContextChanged += new EventHandler(CountryCombo_BindingContextChanged);
}

void CountryCombo_BindingContextChanged(object sender, EventArgs e)
{
this.countryChanged(SelectedValue.ToString()); //********* This where the error occurs if no listener
//********* this.countryChanged is null
}

void CountryCombo_Leave(object sender, EventArgs e)
{
if (this.SelectedIndex == -1 | this.SelectedIndex == 3)
{
this.SelectedIndex = 0;
}
this.countryChanged(SelectedValue.ToString());
}
}

public delegate void CountryChangedHandler (string countryISO3);

public class ProvinceCombo : ComboBox
{
...code

public ProvinceCombo(CountryCombo combo) : base()
{
combo.countryChanged += new CountryChangedHandler(ChangeCountry);
...code
}

public void ChangeCountry(string iso3)
{
...code
}
}
AnswerRe: Delegates Pin
Dustin Metzgar27-Jul-06 7:03
Dustin Metzgar27-Jul-06 7:03 
GeneralRe: Delegates Pin
~~~Johnny~~~27-Jul-06 7:10
~~~Johnny~~~27-Jul-06 7:10 
GeneralRe: Delegates Pin
Dustin Metzgar27-Jul-06 7:34
Dustin Metzgar27-Jul-06 7:34 
GeneralRe: Delegates Pin
~~~Johnny~~~27-Jul-06 8:26
~~~Johnny~~~27-Jul-06 8:26 
QuestionPivotTable and SpreadSheet Components [modified] Pin
hamidreza_buddy27-Jul-06 6:54
hamidreza_buddy27-Jul-06 6:54 
Questionoverload native function Pin
donkaiser27-Jul-06 5:57
donkaiser27-Jul-06 5:57 
AnswerRe: overload native function Pin
J4amieC27-Jul-06 6:02
J4amieC27-Jul-06 6:02 
GeneralRe: overload native function [modified] Pin
donkaiser27-Jul-06 6:06
donkaiser27-Jul-06 6:06 
GeneralRe: overload native function Pin
Ennis Ray Lynch, Jr.27-Jul-06 6:23
Ennis Ray Lynch, Jr.27-Jul-06 6:23 
GeneralRe: overload native function Pin
donkaiser27-Jul-06 6:36
donkaiser27-Jul-06 6:36 
GeneralRe: overload native function Pin
Ennis Ray Lynch, Jr.27-Jul-06 8:17
Ennis Ray Lynch, Jr.27-Jul-06 8:17 
GeneralRe: overload native function Pin
donkaiser27-Jul-06 10:06
donkaiser27-Jul-06 10:06 
QuestionEdit a column in a datagrid without using the edit column [modified] Pin
Mons211027-Jul-06 4:49
Mons211027-Jul-06 4:49 
AnswerRe: Edit a column in a datagrid without using the edit column Pin
LongRange.Shooter28-Jul-06 9:02
LongRange.Shooter28-Jul-06 9:02 
QuestionDetecting when one side of a Socket Connection Closes Pin
Kurt _B27-Jul-06 4:22
Kurt _B27-Jul-06 4:22 
AnswerRe: Detecting when one side of a Socket Connection Closes Pin
Not Active27-Jul-06 5:37
mentorNot Active27-Jul-06 5:37 
GeneralRe: Detecting when one side of a Socket Connection Closes Pin
Kurt _B27-Jul-06 6:20
Kurt _B27-Jul-06 6: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.