有一张数据表格式如下
字段名称 字段类型
Cod varchar
OrderNo varchar
opendate datetime
.....
.....要求在DBGrid中当光标移动到opendate字段中,应显示一个Datetimepicker控件,选择相应的日期后自动保存到该条记录中。
我该如何做呢?
字段名称 字段类型
Cod varchar
OrderNo varchar
opendate datetime
.....
.....要求在DBGrid中当光标移动到opendate字段中,应显示一个Datetimepicker控件,选择相应的日期后自动保存到该条记录中。
我该如何做呢?
解决方案 »
- delphi7的快速排序(大家看对不对..)
- 串口oncomm 事件问题
- ADO连MySql的连接字串是什么?
- TCPCLIENT/TCPSERVER很困惑的问题!!!!!!!!!高手请进!!!!
- 取整和取余?
- 请教各位高手,怎样在程序中从现有数据表中动态得知某一列的数据类型,多谢了。非常紧急,一直在线等
- spcomm从串口采集来的数据问题
- 怎样保存windows附件的画图的颜色设置?
- 关于delphi中分隔符的问题
- nstallShield2003打包的exe安装文件如何解包
- 加急!Delphi中Indy控件关于ReadBuffer和阻塞的问题。
- 在DELPHI2005中如何安装以DPK为扩展名的组件?谢谢回复
DataCol: Integer; Column: TColumn; State: TGridDrawState);
var
OldColor, OldFontColor: TColor;
begin
if CheckCurrencyField(Column.FieldName) then
begin
if (gdFocused in State) then
begin
sncDBCurrencyEdit.Left := Rect.Left + DBG.Left+2;
sncDBCurrencyEdit.Top := Rect.Top + DBG.top+2;
sncDBCurrencyEdit.Width := Rect.Right-Rect.Left;
sncDBCurrencyEdit.Height := Rect.Bottom- Rect.Top;
SetHighLightColor;
if (sncDBCurrencyEdit.Tag=1) and not sncDBCurrencyEdit.Visible then
sncDBCurrencyEdit.Visible := True;
end
else
begin
OldColor := sncDBCurrencyEdit.Color;
OldFontColor := sncDBCurrencyEdit.Font.Color;
SetNormalColor;
DrawCurrencyFrame(DBG.Canvas, Rect, sncDBCurrencyEdit, Column.Field.AsFloat);
sncDBCurrencyEdit.Color := OldColor;
sncDBCurrencyEdit.Font.Color := OldFontColor;
end;
end;
end;
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
begin
if (gdfocused in state) and (column.FieldName='出生年月') then
begin
DateTimePicker1.SetBounds(rect.Left + dbgrid1.Left + 1,rect.Top + dbgrid1.Top +1,
rect.Right - rect.Left ,rect.Bottom -rect.Top);
end;
end;
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
begin
if (gdfocused in state) and (column.FieldName='出生年月') then
begin
DateTimePicker1.SetBounds(rect.Left + dbgrid1.Left + 1,rect.Top + dbgrid1.Top +1,
rect.Right - rect.Left ,rect.Bottom -rect.Top);
end;
end;
procedure TFmfilialinfo.DBGrid1DrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
begin
if (gdfocused in state) and (column.FieldName='出生年月') then
begin
DateTimePicker1.SetBounds(rect.Left + dbgrid1.Left + 1,rect.Top + dbgrid1.Top +1,
rect.Right - rect.Left ,rect.Bottom -rect.Top);
end;
end;我用了这段代码,怎么没有反应阿,datetimepicker还是在form上
procedure TFmfilialinfo.DBGrid1DrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
begin
if (gdfocused in state) and (column.FieldName='opendate') then
begin
DateTimePicker1.SetBounds(rect.Left + dbgrid1.Left + 1,rect.Top + dbgrid1.Top +1,
rect.Right - rect.Left ,rect.Bottom -rect.Top);
end;
end;我用了这段代码,怎么没有反应阿,datetimepicker还是在form上
http://dev.csdn.net/article/53/53439.shtmDBGrid指定列上显示DBComboBox