Hi
Using C#, VS2005 .NET2
I have a custom usercontrol.
Here i have a picturebox (Close) and a CheckedListBox
A public delegate void for CloseControlHan dler();, and event for that
CloseControlEve nt;
A public delegate void for AddFieldToListH andler(string tablename, object
item); and event for that AddFieldToListE vent;
When the user clicks the picture, the picturebox.clic k event fires. Here I
raises my CloseControlEve nt, this allways works fine.
When the user clicks on a item in the CheckListBox the
CheckListBox.It emCheck is fired (besause the CheckOnClick property = true),
I call a method to raise my event AddFieldToListE vent, but always i'll get
the 'Object reference not set....' Error. it seems that the
AddFieldToListE vent i allways NULL.
I do use the:
If ( AddFieldToListE vent != null ) to prevent the application to crash.
Could anyone provide with some hints.
The Code:
public delegate void AddFieldToListH andler(string tablename,
FieldDescriptio nClass description);
public event AddFieldToListH andler AddFieldToListE vent;
public delegate void CloseControlHan dler(Control ClosingControl) ;
public event CloseControlHan dler CloseControlEve nt;
private void picClose_Click( object sender, EventArgs e)
{
if ( CloseControlEve nt !=null)
{
CloseControlEve nt(this);
}
}
private void lstFields_ItemC heck(object sender, ItemCheckEventA rgs e)
{
RaiseAddEvent(_ strTablename, _objField);
}
private void RaiseAddEvent(s tring tablename, FieldDescriptio nClass
description)
{
if ( AddFieldToListE vent != null) // this AddFieldToListE vent is always
null ?????????
AddFieldToListE vent(tablename, description);
}
Kind Regards
Johnny E Jensen
Using C#, VS2005 .NET2
I have a custom usercontrol.
Here i have a picturebox (Close) and a CheckedListBox
A public delegate void for CloseControlHan dler();, and event for that
CloseControlEve nt;
A public delegate void for AddFieldToListH andler(string tablename, object
item); and event for that AddFieldToListE vent;
When the user clicks the picture, the picturebox.clic k event fires. Here I
raises my CloseControlEve nt, this allways works fine.
When the user clicks on a item in the CheckListBox the
CheckListBox.It emCheck is fired (besause the CheckOnClick property = true),
I call a method to raise my event AddFieldToListE vent, but always i'll get
the 'Object reference not set....' Error. it seems that the
AddFieldToListE vent i allways NULL.
I do use the:
If ( AddFieldToListE vent != null ) to prevent the application to crash.
Could anyone provide with some hints.
The Code:
public delegate void AddFieldToListH andler(string tablename,
FieldDescriptio nClass description);
public event AddFieldToListH andler AddFieldToListE vent;
public delegate void CloseControlHan dler(Control ClosingControl) ;
public event CloseControlHan dler CloseControlEve nt;
private void picClose_Click( object sender, EventArgs e)
{
if ( CloseControlEve nt !=null)
{
CloseControlEve nt(this);
}
}
private void lstFields_ItemC heck(object sender, ItemCheckEventA rgs e)
{
RaiseAddEvent(_ strTablename, _objField);
}
private void RaiseAddEvent(s tring tablename, FieldDescriptio nClass
description)
{
if ( AddFieldToListE vent != null) // this AddFieldToListE vent is always
null ?????????
AddFieldToListE vent(tablename, description);
}
Kind Regards
Johnny E Jensen
Comment