Full Explanation - How to cancel row delete at rowdeleting
better_at_medianis.net
Date: 12/27/04
- Previous message: Bret Pehrson: "Re: DataGrid [Attribute] ???"
- Messages sorted by: [ date ] [ thread ]
Date: 27 Dec 2004 14:02:55 -0800
Full Explanation - How to cancel row delete at rowdeleting
This problem solution satisfies in complete.
Code is in C#, but if you need just translate to vb.net, and it will
works too.
Idea is to throw exception which abort (cancel) delete command at
rowdeleting.
We catch this exception at application level, and if we detect that is
"our" exception, just do nothing.
Silent pass thought.
Once you add this method, you can use for all deleting, changing or all
other stops, which you may need.
Best Regards
Milan Better
1.Step is to declare our Exception (so we can detect at application
level which exception is our)
public class myDataException :Exception
{
}
2.Step is to add event handler Application.ThreadException, in main
function of our project
[STAThread]
static void Main()
{
Application.ThreadException +=new
System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
Application.Run(new MainForm());
}
private static void Application_ThreadException(object sender,
System.Threading.ThreadExceptionEventArgs e)
{
//Fill here
}
3.Step is fill event handler we just created!
private static void Application_ThreadException(object sender,
System.Threading.ThreadExceptionEventArgs e)
{
if(e.Exception is myDataException)
{
return; //if this is our exception, just pass trought silent
}
else throw e.Exception; //all other exceptions which we do not handle
}
4.Step is fire exception at rowdeleting event handler
private void myTableRowDeleting(object sender, myTableRowChangeEvent e)
{
throw new myDataException();
}
- Previous message: Bret Pehrson: "Re: DataGrid [Attribute] ???"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|