J
Johnny E Jensen
Hi
Using C#, VS2005 .NET2
I have a custom usercontrol.
Here i have a picturebox (Close) and a CheckedListBox
A public delegate void for CloseControlHandler();, and event for that
CloseControlEvent;
A public delegate void for AddFieldToListHandler(string tablename, object
item); and event for that AddFieldToListEvent;
When the user clicks the picture, the picturebox.click event fires. Here I
raises my CloseControlEvent, this allways works fine.
When the user clicks on a item in the CheckListBox the
CheckListBox.ItemCheck is fired (besause the CheckOnClick property = true),
I call a method to raise my event AddFieldToListEvent, but always i'll get
the 'Object reference not set....' Error. it seems that the
AddFieldToListEvent i allways NULL.
I do use the:
If ( AddFieldToListEvent != null ) to prevent the application to crash.
Could anyone provide with some hints.
The Code:
public delegate void AddFieldToListHandler(string tablename,
FieldDescriptionClass description);
public event AddFieldToListHandler AddFieldToListEvent;
public delegate void CloseControlHandler(Control ClosingControl);
public event CloseControlHandler CloseControlEvent;
private void picClose_Click(object sender, EventArgs e)
{
if ( CloseControlEvent !=null)
{
CloseControlEvent(this);
}
}
private void lstFields_ItemCheck(object sender, ItemCheckEventArgs e)
{
RaiseAddEvent(_strTablename, _objField);
}
private void RaiseAddEvent(string tablename, FieldDescriptionClass
description)
{
if ( AddFieldToListEvent != null) // this AddFieldToListEvent is always
null ?????????
AddFieldToListEvent(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 CloseControlHandler();, and event for that
CloseControlEvent;
A public delegate void for AddFieldToListHandler(string tablename, object
item); and event for that AddFieldToListEvent;
When the user clicks the picture, the picturebox.click event fires. Here I
raises my CloseControlEvent, this allways works fine.
When the user clicks on a item in the CheckListBox the
CheckListBox.ItemCheck is fired (besause the CheckOnClick property = true),
I call a method to raise my event AddFieldToListEvent, but always i'll get
the 'Object reference not set....' Error. it seems that the
AddFieldToListEvent i allways NULL.
I do use the:
If ( AddFieldToListEvent != null ) to prevent the application to crash.
Could anyone provide with some hints.
The Code:
public delegate void AddFieldToListHandler(string tablename,
FieldDescriptionClass description);
public event AddFieldToListHandler AddFieldToListEvent;
public delegate void CloseControlHandler(Control ClosingControl);
public event CloseControlHandler CloseControlEvent;
private void picClose_Click(object sender, EventArgs e)
{
if ( CloseControlEvent !=null)
{
CloseControlEvent(this);
}
}
private void lstFields_ItemCheck(object sender, ItemCheckEventArgs e)
{
RaiseAddEvent(_strTablename, _objField);
}
private void RaiseAddEvent(string tablename, FieldDescriptionClass
description)
{
if ( AddFieldToListEvent != null) // this AddFieldToListEvent is always
null ?????????
AddFieldToListEvent(tablename, description);
}
Kind Regards
Johnny E Jensen