📄 deletingrecords.htm
字号:
<html>
<head>
<title>Deleting Records</title>
</head>
<!--#include virtual="/inc/header.php"-->
<table width="100%" border="0" cellspacing="0" cellpadding="2" bgcolor="#FFFFFF">
<tr>
<td align="left">
<span style="font-family:Helvetica,Arial; font-size:12pt; color:#000000"><b>Deleting Records
<br>
</b></span>
</td>
<td align="right">
<font face="Arial" size="2">
<a href="editingrecords.htm">Previous</a>
<a href="overview.htm">Top</a>
<a href="sortingrecordswithindexes.htm">Next</a>
</font>
</td>
</tr>
</table>
<br><br>
<span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000">
<br>
Use the <a href=tdataset_delete.htm>Delete </a>method to delete the current record in an active dataset.When the <i>Delete</i> method is called,
<br>
<br>
<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td width="14"><span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000"><font face="Symbol" size="2" color="#000000">·</font></span></td><td><span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000">The dataset receives a <i>BeforeDelete</i> event.
<br>
</span></td></tr></table><table width="100%" border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td width="14"><span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000"><font face="Symbol" size="2" color="#000000">·</font></span></td><td><span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000">The dataset attempts to delete the current record.
<br>
</span></td></tr></table><table width="100%" border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td width="14"><span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000"><font face="Symbol" size="2" color="#000000">·</font></span></td><td><span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000">The dataset returns to the <i>dsBrowse</i> state.
<br>
</span></td></tr></table><table width="100%" border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td width="14"><span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000"><font face="Symbol" size="2" color="#000000">·</font></span></td><td><span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000">The dataset receives an <i>AfterDelete</i> event.
<br>
</span></td></tr></table><table width="100%" border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td><span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000"></span></td><td></td></tr></table><span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000">
<br>
If want to prevent the deletion in the <i>BeforeDelete</i> event handler, you can call the global <i>Abort</i> procedure:
<br>
<br>
</span><span style="font-family:Courier New; font-size:8pt; color:#000000"><b>procedure</b> TForm1.TableBeforeDelete (Dataset: TDataset)<b>begin</b>
<br>
<b>if</b> MessageDlg(<span style="font-family:Courier New; font-size:8pt; color:#000080">'Delete This Record?'</span></span><span style="font-family:Courier New; font-size:8pt; color:#000000">, mtConfirmation, mbYesNoCancel, <span style="font-family:Courier New; font-size:8pt; color:#000080">0</span></span><span style="font-family:Courier New; font-size:8pt; color:#000000">) <> mrYes <b>then</b>
<br>
Abort;
<br>
<b>end</b>;
<br>
</span><span style="font-family:Helvetica,Arial; font-size:10pt; color:#000000">
<br>
If <i>Delete</i> fails, it generates an <i>OnDeleteError</i> event. If the <i>OnDeleteError </i>event handler can't correct the problem, the dataset remains in <i>dsEdit</i> state. If <i>Delete</i> succeeds, the dataset reverts to the <i>dsBrowse</i> state and the record that followed the deleted record becomes the current record.
<br>
If you provide a navigator component on your forms, users can delete the current record by clicking the navigator's Delete button. In code, you must call <i>Delete</i> explicitly to remove the current record.
<br>
</span></span>
<!--#include virtual="/inc/footer.php"-->
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -