DateTimePicker inside a DBGrid  

Here's how to place a TDateTimePicker into a DBGrid. Create visually more attractive user interfaces for editing date/time fields inside a DBGrid - place a drop down calendar into a cell of a DBGrid.  

procedure TForm1.DBGrid1DrawColumnCell
(Sender: TObject;
const Rect: TRect;
DataCol: Integer;
Column: TColumn;
State: TGridDrawState);
begin
if (gdFocused in State) then
begin
if (Column.Field.FieldName = 'DateAdded') then
with DateTimePicker do
begin
Left := Rect.Left + DBGrid1.Left + ;
Top := Rect.Top + DBGrid1.Top + ;
Width := Rect.Right - Rect.Left + ;
Width := Rect.Right - Rect.Left + ;
Height := Rect.Bottom - Rect.Top + ; Visible := True;
end;
end
end; procedure TForm1.DBGrid1ColExit(Sender: TObject);
begin
if DBGrid1.SelectedField.FieldName = 'DateAdded' then
DateTimePicker.Visible := False
end; procedure TForm1.DBGrid1KeyPress(Sender: TObject; var Key: Char);
begin
if (key = Chr()) then Exit; if (DBGrid1.SelectedField.FieldName = 'DateAdded') then
begin
DateTimePicker.SetFocus;
SendMessage(DateTimePicker.Handle, WM_Char, word(Key), );
end
end; procedure TForm1.DateTimePickerChange(Sender: TObject);
begin
if DBGrid1.DataSource.State in [dsEdit, dsInsert] then
ADOTable1DateAdded.Value := DateTimePicker.DateTime;
end; procedure TForm1.DateTimePickerDropDown(Sender: TObject);
begin
DBGrid1.DataSource.Edit;
end;

DBGrid中插入DateTimePicker的更多相关文章

  1. 如何在latex 中插入EPS格式图片

    如何在latex 中插入EPS格式图片 第一步:生成.eps格式的图片 1.利用visio画图,另存为pdf格式的图片 利用Adobe Acrobat裁边,使图片大小合适 另存为.eps格式,如下图所 ...

  2. Latex中插入C语言代码

    Latex是一个文本排版的语言,能排版出各种我们想要的效果.而且用代码排版的优点是易于修改板式,因此在文本内容的排版时,Latex应用十分广泛. 当我们需要在Latex中插入代码时,就需要用到 \us ...

  3. 【转载】在HTML中插入swf文件(转)

    在HTML中插入swf文件(转) 在网页里面插入swf,再平常不过了,一般会想到如下代码: Html代码 <object classid="clsid:D27CDB6E-AE6D-11 ...

  4. 在MySQL向表中插入中文时,出现:incorrect string value 错误

    在MySQL向表中插入中文时,出现:incorrect string value 错误,是由于字符集不支持中文.解决办法是将字符集改为GBK,或UTF-8.      一.修改数据库的默认字符集   ...

  5. SQL语句 在一个表中插入新字段

    SQL语句 在一个表中插入新字段: alter table 表名 add 字段名 字段类型 例: alter table OpenCourses add Audio varchar(50)alter ...

  6. Markdown中插入数学公式的方法

    Markdown中插入数学公式的方法 文章来源:http://blog.csdn.net/xiahouzuoxin/article/details/26478179 自从使用Markdown以来,就开 ...

  7. java POI实现向Excel中插入图片

          做Web开发免不了要与Excel打交道.今天老大给我一个任务-导出Excel.开始想的还是蛮简单的,无非就是查找,构建Excel,response下载即可.但是有一点不同,就是要加入图片, ...

  8. 使用C#向ACCESS中插入数据

    使用C#向ACCESS中插入数据   1.创建并打开一个OleDbConnection对象 string strConn = " Provider = Microsoft.Jet.OLEDB ...

  9. 快速向表中插入大量数据Oracle中append与Nologging

    来源于:http://blog.sina.com.cn/s/blog_61cd89f60102e7gi.html 当需要对一个非常大的表INSERT的时候,会消耗非常多的资源,因为update表的时候 ...

随机推荐

  1. dp--01背包,完全背包,多重背包

    背包问题 以下代码 n是物品个数,m是背包容积 物品价值和重量int v[maxn],w[maxn]; 01背包 模板 for(int i = 0; i < n; i++) { for(int ...

  2. flutter ListView 页面滚动组件

    ListView class A scrollable list of widgets arranged linearly. ListView is the most commonly used sc ...

  3. C字符指针数组的使用

    #include <stdio.h> #include <stdlib.h> int main(){ //字符数组的使用 char str[] = {'z','b','c',' ...

  4. loj #137 and #6021

    最小瓶颈路 加强版 重构树 最小生成树在合并 (x, y) 时,新建节点 z,link(x, z), link(y, z), 新建节点的权值为 w_{x,y}, 这样的 话任意两点的 answer 为 ...

  5. 【概率论】5-8:Beta分布(The Beta Distributions)

    title: [概率论]5-8:Beta分布(The Beta Distributions) categories: - Mathematic - Probability keywords: - Th ...

  6. realloc()函数

    原型:extern void *realloc(void *mem_address, unsigned int newsize); 参数: mem_address: 要改变内存大小的指针名 newsi ...

  7. 《挑战30天C++入门极限》C++运算符重载赋值运算符

        C++运算符重载赋值运算符 自定义类的赋值运算符重载函数的作用与内置赋值运算符的作用类似,但是要要注意的是,它与拷贝构造函数与析构函数一样,要注意深拷贝浅拷贝的问题,在没有深拷贝浅拷贝的情况下 ...

  8. SSM + ehcache 异常

    异常如下: 十二月 26, 2017 1:24:44 下午 org.apache.jasper.servlet.TldScanner scanJars 信息: At least one JAR was ...

  9. java读取文件内容并输出到控制台,java中实现文件复制

    public class TestFileInputStream { public static void main(String [] args) { //读取指定文件中内容,并在控制台输出 Fil ...

  10. Spring Boot|监控-Actuator

    Spring Boot 为我们提供了一个生产级特性-Actuator,包含很多实际有用的API,下面我们就一起来看看这些API. 一.Actuator 首先在程序中引入Actuator <!-- ...