请问c#中有没有类似delphi的beforeDelete事件呢?

laoguang_2008 2008-04-21 04:20:24
请问c#中有没有类似delphi的beforeDelete事件呢?
我想在删除记录时弹出确认对话框.但不知道在哪儿加代码.
...全文
130 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
patrickpan 2008-04-23
  • 打赏
  • 举报
回复
[Quote=PatrickPan]
这个控件的官网:
http://www.devexpress.com/Products/NET/
[/Quote]
laoguang_2008 2008-04-23
  • 打赏
  • 举报
回复
太谢谢patrickpan了,非常感谢,另外问一下,你说的这些资料在哪里可以找到呢?msdn中都有吗?
patrickpan 2008-04-23
  • 打赏
  • 举报
回复
[Quote=PatrickPan]
这样应该就没问题了:
switch (e.Button.ButtonType)
{
case NavigatorButtonType.Remove:
if (MessageBox.Show("确认删除这条记录吗?", "询问", MessageBoxButtons.YesNo,MessageBoxIcon.Warning) == DialogResult.Yes)
{

进口_合同TableAdapter.Update(cessdbDataSet.进口_合同);
cessdbDataSet.AcceptChanges();
MessageBox.Show("删除成功!", "提示");
}
else
{
e.Handled = true;
}
break;
default:
break;
[/Quote]
patrickpan 2008-04-23
  • 打赏
  • 举报
回复
[Quote=PatrickPan]
你用的是第三方控件,

using DevExpress.XtraEditors;

private void dataNavigator1_ButtonClick(object sender, NavigatorButtonClickEventArgs e) {
if (e.Button.ButtonType == NavigatorButtonType.Remove)
if (MessageBox.Show("Do you really want to delete the record?", "Warning",
MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
e.Handled = true;
}

这是官方版的例子。设置e.Handled的值决定是否在表中标记删除状态。
[/Quote]
laoguang_2008 2008-04-22
  • 打赏
  • 举报
回复
我做的就是winform的程序呵呵
fuda_1985 2008-04-22
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 laoguang_2008 的回复:]
我已经试过了,在按钮中添加提示有个问题,即使用户选择不删除这条记录,但在dbgrid中该条记录还是会消失不见了。
switch (e.Button.ButtonType)
{
case NavigatorButtonType.Remove:
if (MessageBox.Show("确认删除这条记录吗?", "询问", MessageBoxButtons.YesNo) == DialogResult.Yes)
{

进口_…
[/Quote]
这个是Winform里的做法,
webForm里就加个js就行了的。不可能选了no还会删除的情况。要不就是你的控制搞错了。
laoguang_2008 2008-04-22
  • 打赏
  • 举报
回复
谢谢patrickpan的指点,具体到我这个问题有什么解决办法吗?
patrickpan 2008-04-22
  • 打赏
  • 举报
回复
[Quote=PatrickPan]
C#和Delphi还是有很打的区别的,既然用C#了,思维就不能还局限在原来的Delphi上。
我一哥们从Delphi转向C#,在Ui界面上建立了很多文本控件,然后把复杂的SQL语句都写在里面。
典型的Delphi思维。
但在C#中是绝对不能容忍的,这样使UI和数据访问更加混乱。
[/Quote]
laoguang_2008 2008-04-22
  • 打赏
  • 举报
回复
我已经试过了,在按钮中添加提示有个问题,即使用户选择不删除这条记录,但在dbgrid中该条记录还是会消失不见了。
switch (e.Button.ButtonType)
{
case NavigatorButtonType.Remove:
if (MessageBox.Show("确认删除这条记录吗?", "询问", MessageBoxButtons.YesNo) == DialogResult.Yes)
{

进口_合同TableAdapter.Update(cessdbDataSet.进口_合同);
cessdbDataSet.AcceptChanges();
MessageBox.Show("删除成功!", "提示");
}
break;
default:
break;
ojekleen 2008-04-22
  • 打赏
  • 举报
回复


if (MessageBox.Show("确认删除吗?","警告",MessageBoxButtons.YesNo) == DialogResult.Yes)
{

}
ojekleen 2008-04-22
  • 打赏
  • 举报
回复
那你可以在删除按钮的click事件中加提示啊
laoguang_2008 2008-04-22
  • 打赏
  • 举报
回复
我用导航条和dbgrid来显示数据,当直接点击导航条上的删除按钮后,没有任何提示。所以想自己加提示。
laoguang_2008 2008-04-22
  • 打赏
  • 举报
回复
自己顶一下
WPViewPDF is a powerful pdf viewer control which allows you to view and print PDF data. The data can be loaded from memory, file or stream. As "PLUS" edition it can be used to merge PDF files into a new, single file. You can extract PDF pages or delete pages. It is also possible to add vector and text graphic to PDF files (stamping). Unlike many competing products WPViewPDF displays even large PDF files instantly. This component has been developed as a window class which makes it compatible to most Windows based development systems. Out of the box it can be used as ActiveX (OCX), in .NET development environments (i.e. Visual Studio 2010) and as VCL in Delphi and C++Builder. You can download a demo which includes the component as .NET, Delphi and ActiveX component and a small example application. The source for the components (C# and Pascal) is included as well. It also includes an executable demo. The new Version 3 is the result of extensive work. We completely re-thought the logic which is require to load, render and manipulate PDF data to create this new version. It makes use of clever and effective caching for quick response times. It also makes use of multithreading for better user interaction. We revised the PrintHDC method - printing to any windows device should be now much easier to do than before and produce higher quality. The multithreaded scrolling viewer can change quickly change between zoom states and various layout modes, including multi column display and side by side page layout. It can also display a separate thumbnail view to the PDF. Unlike version 1 and 2 the new version 3 uses floating point numbers for graphic output which offers better print results for many PDF files. Despite the higher text rendering quality, printing will be faster since less data has to be transferred to the printer. Version 3 PLUS introduce a new stamping method which also it to place objects or highlighting rectangles on the page. This objects can be moved and sized by the user. But we also implemented the scripted stamping because it makes it so easy to add titles or page numbers to a range of pages. You can modify the existing bookmarks by loading the structure as XML. It is also possible to extract the current bookmarks as XML. Text extraction now also creates text in rich text format (RTF) - here the logic tries to make use of PDF tags to keep text together which belongs together. The field support has been enhanced for better compatibility with existing PDF files. We work to add the ability to create new fields to the "PLUS" Edition. Supports 32 bit and also 64 bit applications!

110,561

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧