FDataSource :=TDataSource.Create(self);
FDBGrid.FreeNotification(self);
FADOQuery.FreeNotification(self);
FDataSource.FreeNotification(self);
FDataSource.DataSet:=FADOQuery;
with FDBGrid do
begin
DataSource:=FDataSource;
Ctl3D:=false;
Visible:=false;
ParentCtl3D:=false;
Options:=[dgColLines,dgRowLines,dgRowSelect,dgAlwaysShowSelection,dgConfirmDelete,dgCancelOnExit];
OnMouseUp:=DoFDBGridMouseUp;
OnKeyDown:=DoFDBGridKeyDown;
end;
with self do
begin
ParentCtl3D:=false;
Ctl3D:=false;
end;
end;
procedure TDBLookUpEdit.CreateWnd;
begin
FCreating := True;
try
inherited CreateWnd;
finally
FCreating := False;
end;
end;
procedure TDBLookUpEdit.CMBidimodechanged(var Message: TMessage);
begin
inherited;
FDBGrid.BiDiMode := BiDiMode;
end;
procedure TDBLookUpEdit.CMEnabledchanged(var Message: TMessage);
begin
inherited;
FDBGrid.Enabled := Enabled;
end;
procedure TDBLookUpEdit.CMVisiblechanged(var Message: TMessage);
begin
inherited;
end;
procedure TDBLookUpEdit.Notification(AComponent: TComponent;
Operation: TOperation);
begin
inherited Notification(AComponent, Operation);
if (AComponent = FDBGrid) and (Operation = opRemove) then FDBGrid:= nil;
if (AComponent = FADOQuery) and (Operation = opRemove) then FADOQuery:= nil;
if (AComponent = FDataSource) and (Operation = opRemove) then FDataSource:= nil;
end;
procedure TDBLookUpEdit.SetParent(AParent: TWinControl);
begin
inherited SetParent(AParent);
if FDBGrid <> nil then FDBGrid.Parent := self.Owner as TForm;
end;
procedure TDBLookUpEdit.SetBounds(ALeft, ATop, AWidth, AHeight: Integer);
begin
inherited;
if FDBGrid <> nil then
with FDBGrid do
begin
Top:=-Height;
Left:=-Width;
end;
end;
procedure TDBLookUpEdit.SetRecText(FieldNo: integer);
begin
self.SetFocus;
self.SelectAll;
if (FADOQuery.Connection <>nil) or (FADOQuery.ConnectionString <>'''''''') then
if FADOQuery.Active then
if FADOQuery.RecordCount > then
if FADOQuery.FieldCount>FieldNo then
begin
self.Text:=FDBGrid.Fields[FieldNo].Text;
self.SelectAll;
self.SetFocus;
end;
end;
procedure TDBLookUpEdit.FDoEnter(Sender: TObject);
var
p :TPoint;
begin
P:=self.ClientToParent(point(,self.Height),(self.Owner as TForm));
if (FDBGrid.Height p.y )<=(self.Owner as TForm).Height then
begin
FDBGrid.Top :=p.y ;
end
else begin
FDBGrid.Top :=p.y--self.Height -FDBGrid.Height;
end;
FDBGrid.Left :=p.x ;
FDBGrid.BringToFront;
FDBGrid.Visible:=true;
if self.Text='''''''' then SetRecText();
self.SelectAll;
if (self.Text<>'''''''') and FADOQuery.Active then
FADOQuery.Locate(FKeyField, self.text,[lopartialkey]);
end;
procedure TDBLookUpEdit.FDoExit(Sender: TObject);
begin
if not FDBGrid.Focused then FDBGrid.Visible:=false;
end;
procedure TDBLookUpEdit.DoFDBGridMouseUp(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
SetRecText();
FDBGrid.Visible:=false;
end;
procedure TDBLookUpEdit.DoFDBGridKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key= then
begin
SetRecText();
FDBGrid.Visible:=false;
key:=;
end;
end;
procedure TDBLookUpEdit.CNCommand(var Message: TWMCommand);
begin
case Message.NotifyCode of
EN_CHANGE:
begin
if not FCreating then
if Assigned(FOnChange) then FOnChange(self);
end;
EN_KILLFOCUS:
begin
if Assigned(FOnExit) then FOnExit(self);
FDoExit(self);
end;
EN_SETFOCUS:
begin
if Assigned(FOnEnter) then FOnEnter(self);
FDoEnter(self);
end;
end;
end;
procedure TDBLookUpEdit.DblClick;
begin
inherited;
FDoEnter(self);
end;
function TDBLookUpEdit.GetDataSource: TDataSource;
begin
Result := FDBGrid.DataSource;
end;
procedure TDBLookUpEdit.SetDataSource(Value: TDataSource);
begin
if Value <> FDBGrid.Datasource then FDBGrid.DataSource := Value;
if Value <> nil then Value.FreeNotification(Self);
end;
procedure TDBLookUpEdit.KeyDown(var Key: Word; Shift: TShiftState);
begin
inherited;
if FDBGrid.Visible then
begin
if (key=) or (key=) then
begin
SendMessage(FDBGrid.Handle,WM_KEYDOWN,key,);
key:=;
end;
if key= then
begin
SetRecText();
FDBGrid.Visible:=false;

偶写的第一个控件,一个用选择代替输入的Edit控件…的更多相关文章

  1. 增加duilib edit控件的提示功能和多种文字颜色

    转载请说明原出处,谢谢~~:http://blog.csdn.net/zhuhongshu/article/details/41786407 duilib的CEditUI控件内部使用了win32的原生 ...

  2. Delphi在Listview中加入Edit控件

    原帖 : http://www.cnblogs.com/hssbsw/archive/2012/06/03/2533092.html Listview是一个非常有用的控件,我们常常将大量的数据(如数据 ...

  3. ASP.NET自定义控件组件开发 第一章 第一章:从一个简单的控件谈起

    第一章:从一个简单的控件谈起 系列文章链接: ASP.NET自定义控件组件开发 第一章 待续 ASP.NET自定义控件组件开发 第一章 第二篇 接着待续 ASP.NET自定义控件组件开发 第一章 第三 ...

  4. QT 创建一个具有复选功能的下拉列表控件

    最近研究了好多东西,前两天突然想做一个具有复选功能的下拉列表框.然后在网上"学习"了很久之后,终于发现了一个可以用的,特地发出来记录一下. 一.第一步肯定是先创建一个PROJECT ...

  5. 【React】开发一个城市选择控件

    想到做这个,是因为无意中在github上看到了这一个仓库https://github.com/lunlunshiwo/ChooseCity,做的就是一个城市选择控件,是用vue写的,说的是阿里的一道题 ...

  6. 一个Demo让你掌握Android所有控件

    原文:一个Demo让你掌握Android所有控件 本文是转载收藏,侵删,出处:"安卓巴士"      下面给出实现各个组件的源代码: 1.下拉框实现--Spinner packag ...

  7. 基于 element-plus 封装一个依赖 json 动态渲染的查询控件

    前情回顾 基于 el-form 封装一个依赖 json 动态渲染的表单控件 Vue3 封装第三方组件(一)做一个合格的传声筒 功能 使用 vue3 + element-plus 封装了一个查询控件,专 ...

  8. C++ 一个程序获取另一个程序Edit控件的内容

    //一个程序获取另一个程序Edit控件的内容 //根据指定程序的标题名获取改程序窗口的句柄 HWND hWnd=::FindWindow(NULL,"zhang001"); if( ...

  9. android 给LinearLayout中添加一定数量的控件,并让着一定数量的控件从右到左移动,每隔若干秒停顿一下,最后一个view链接第一个view,然后继续移动循环往复,形成一个死循环简单动画效果

    主类:IndexAnimationLinearLayout.java package com.yw.sortlistview; import java.util.ArrayList; import j ...

随机推荐

  1. LVS(二)NAT模型配置

    NAT配置模式 环境说明 LVS服务器(在eth0:0上设置VIP为:192.168.159.200/24) Eth0:192.168.159.133/24   GW:192.168.159.2 Et ...

  2. Python:bs4的使用

    概述 bs4 全名 BeautifulSoup,是编写 python 爬虫常用库之一,主要用来解析 html 标签. 一.初始化 from bs4 import BeautifulSoup soup ...

  3. 【面试】足够应付面试的Spring事务源码阅读梳理(建议珍藏)

    Starting from a joke 问:把大象放冰箱里,分几步? 答:三步啊,第一.把冰箱门打开,第二.把大象放进去,第三.把冰箱门带上. 问:实现Spring事务,分几步? 答:三步啊,第一. ...

  4. Zuul之Filter详解

    Zuul详解 官方文档:https://github.com/Netflix/zuul/wiki/How-it-Works Zuul的中心是一系列过滤器,能够在HTTP请求和响应的路由过程中执行一系列 ...

  5. Linux基本命令操作

    3.1  Linux终端介绍.Shell提示符.Bash基本语法 3.1.1  登录LINUX终端 两种终端仿真器:1.GNOME桌面的GHOME Terminal : 2.KDE桌面的Konsole ...

  6. 在虚拟机中搭建qduoj(一)——准备工作

    为缩减篇幅,已略去ubuntu镜像下载.虚拟机(VirtualBox.VMware)安装等操作,若有疑问请搜索相关教程. 1.虚拟机系统安装 本教程使用Ubuntu16.04 server版本(des ...

  7. 华途软件受控XML转EXCEL

    公司加密系统用的是华途的产品.最近公司高层想要重新梳理公司信息安全管理情况,华途加密系统的梳理和优化是重中之重. 今天公司领导要求IT导出目前系统中所有软件.后缀的受控情况,然后IT吭哧吭哧地把华途软 ...

  8. FelxCell常用属性设置(未完待续......)

    this.grid1.AllowUserPaste//返回或设置是否允许用户粘贴文字和格式 grid1.Cell(Rows, 1).WrapText = true;//设置单元格自动换行

  9. kali中的postgres怎么连接

    metasploit,默认使用的是postgresql数据库.在BT5或是Kali等专业的渗透系统中,postgresql已经被默认安装. 执行msfdb init会自动创建一个默认的用户名密码都是m ...

  10. python3 字符串/列表/元组(str/list/tuple)相互转换方法及join()函数的使用

    在抓取网络数据的时候,有时会用正则对结构化的数据进行提取,比如 href="https://www.1234.com"等.python的re模块的findall()函数会返回一个所 ...