1:Onsettext
2:..
3:CacheUpdate
4:On DateSource DataChange Event:
if TDataSource(Sender).DataSet.Eof then TDataSource(Sender).DataSet.Cancel;
5:.........
2:..
3:CacheUpdate
4:On DateSource DataChange Event:
if TDataSource(Sender).DataSet.Eof then TDataSource(Sender).DataSet.Cancel;
5:.........
解决方案 »
- 如何将用户指定的记录的某一字段值传给一个变量
- delphi的activex form资源释放的问题,十万火急
- 数据库table1某字段aaa每个格的英文单词如apple 变成a p p l e.(cm)
- 在32位操作系统下,如何改变Windows的默认打印机??
- Fastreport2.x的報表定義文件(.frf)如何在Fastreport3.x(.fr3)中使用???
- 通信监控
- 一段vb代码 翻译成delphi 求指导
- 如何在对等网上进行语音通话
- 如何将BMP文件转化为JPG文件?不只是变一下扩展名,要压缩其大小才行。
- 在Delphi中怎样实现数据库中超长文本(包括表格与图片)字段的编辑与存取?
- Delphi5的quickreport预缆时掉线有没解决?关闭预缆时返回的query1总会回到first吗?
- UDL文件怎么写?它的内容具体包括什么?能否给一个完整的例子
2)使用OnKeyPress事件
if Key = #13 then begin
S := TDBGrid(Sender).SelectedField.Text;
ShowMessage(S);
end;
3)保存之前,调用Post。
4)捕获DBGrid的OnKeyDown事件,判断当DataSet为EOF时,DBGrid的ReadOnly属性为True, 否则为False,屏蔽输入。如果Key为VK_INSERT时,设置Key := 0;如下例:
case Key of
VK_INSERT:
KEY := 0;
else
if TDBGrid(Sender).DataSource.DataSet.Eof then
TDBGrid(Sender).ReadOnly := True
else
TDBGrid(Sender).ReadOnly := False;
end;5) 定位焦点
with TDBGrid(Sender) do
try
DataSource.DataSet.DisableControls();
DataSource.Dataet.First;
DataSource.DataSet.MoveBy(cFocusRow); // Specify the Row index, 0 based.
SelectedIndex := cFocusCol; // Specify the col index, 0 based.
SetFocus;
finally
DataSource.DataSet.EnableControls();
end;
关于选择前三个字符,似乎有点烦。可以实现,但没有实现的必要。
在implementation下定义:
type
Emy=class(exception);用table或query建立永久字段,选中易出错的字段,在onsettext中内容如下:procedure TForm1.Table1filedname1SetText(Sender: TField;
const Text: String);
begin
try
sender.Value:=text;
except
raise emy.Create('类型不对');
end;
end;
找这个错误可能只有这一种方法了,不过一定行的。
针对第1点,使用DataSet的FieldDefs属性,指定字段类型的方法较好,这样编程更简单,可以校验各种类型,而不仅仅是字符串类型。
针对第4点,我觉得好的做法应该是将DBGrid的Options属性中的dgEditing设为False。
2、那是因为你还没有提交,在 showmessage 前加上tabel1.post试试。
4。if (key=vk_return) and (table1.eof) then key=0;