Hi!
I inherited KryptonToolkit ListBox control to get SelectedItemChanging event.
public class CPListBox : KryptonListBox
{
public event CancelEventHandler SelectedIndexChanging;
protected virtual void OnSelectedIndexChanging(CancelEventArgs e)
{
SelectedIndexChanging(this, e);
}
protected override void OnSelectedIndexChanged(EventArgs e)
{
CancelEventArgs cArgs = new CancelEventArgs();
OnSelectedIndexChanged(cArgs);
if(!cArgs.Cancel)
{
base.OnSelectedIndexChanged(e);
}
}
}
In form I handle event with code:
void UsersListBoxSelectedIndexChanging(object sender, CancelEventArgs e)
{
if(_presenter.CurrentUser.IsModified)
{
MessageBox.Show("Nie zapisales zmian!");
e.Cancel = true;
}
}
And I got stackOverflow ;) Exception. Maybe someone now what is wron with this code?