如题.
在TQuery中有一个字段objfun, 希望录入时可以有一个下拉列表
增加 1
删除 2
编辑 3
保存 4
打印 5
查询 6
审核 7我应该怎样做?使得我选择"增加"或其它它存入数据库的是对应的数字?
在TQuery中有一个字段objfun, 希望录入时可以有一个下拉列表
增加 1
删除 2
编辑 3
保存 4
打印 5
查询 6
审核 7我应该怎样做?使得我选择"增加"或其它它存入数据库的是对应的数字?
解决方案 »
- delphi 实现报表打印问题 不能调用QuickRep
- 请问怎样用程序改变当前机器的IE代理服务器地址?
- 请问各位大虾关于打印(frReport)的一个问题~~~~!!!
- 大家在实际开发中如何解决数据库冲突的问题,欢迎大家发言
- 熟悉日期操作的高人来帮忙啊
- ***********是男人的就进来看看,不知道不要紧!*********
- 我的ExpressPrinting System Version 2.4.8为什么不支持ExpressQuantumGrid Version 4.2 ?
- NMPop3邮件下载问题(急)!!!!
- 可用分6688,吉利!散分
- 怎么让 TStringList 变量指向一个空(nil)?
- 谁能给我一些有关以下几个函数使用的例程?
- 各位对金蝶K3的界面感觉怎么样?对不对你胃口?
如:
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DBCtrls, DB, DBTables, Grids, DBGrids;type
TForm1 = class(TForm)
DataSource1: TDataSource;
DBGrid1: TDBGrid;
Table1: TTable;
DBComboBox1: TDBComboBox;
procedure DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect;
Field: TField; State: TGridDrawState);
procedure DBGrid1ColExit(Sender: TObject);
procedure DBGrid1KeyPress(Sender: TObject; var Key: Char);
procedure DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect;
Field: TField; State: TGridDrawState);
begin
if (gdFocused in State) then
begin
if ( Field.FieldName = DBComboBox1.DataField ) then
begin
DBComboBox1.Left := Rect.Left + DBGrid1.Left;
DBComboBox1.Top := Rect.Top + DBGrid1.top;
DBComboBox1.Width := Rect.Right - Rect.Left;
DBComboBox1.Height := Rect.Bottom - Rect.Top;
DBComboBox1.Visible := True;
end;
end;
end;procedure TForm1.DBGrid1ColExit(Sender: TObject);
begin
If DBGrid1.SelectedField.FieldName = DBComboBox1.DataField then
begin
DBComboBox1.Visible := false;
end;
end;procedure TForm1.DBGrid1KeyPress(Sender: TObject; var Key: Char);
begin
if (key <> chr(9)) then
begin
if (DBGrid1.SelectedField.FieldName=DBComboBox1.DataField) then
begin
DBComboBox1.SetFocus;
SendMessage(DBComboBox1.Handle, WM_Char, word(Key), 0);
end;
end;
end;procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
if Table1.FieldByName('SIZE').AsInteger = 2 then
begin
DBGrid1.Canvas.Font.Color:=clred;
DBGrid1.Canvas.Brush.color:=clyellow;
end else
begin
DBGrid1.Canvas.Font.Color:=clblue;
DBGrid1.Canvas.Brush.color:=clBtnFace;
end;
DBGrid1.DefaultDrawColumnCell(rect,datacol,column,state);
end;end.
卖个乖
-------------------------------------------------------------
寻寻寻,寻斑竹小小在线
如果您觉的您对Delphi 感兴趣或是很想学的更好些或者是对Delphi 有更深的认识,我们可以一起交流;
呵呵
www.nxrs.net/bbs
谢谢,别抛砖
-----------------------------------------------------------------
声明:在那儿交流都一样的,我现在还是认为Csdn是最好的,呵呵
1\是TQuery而且带有参数,而不是TTable,所以picklist和lookup可能不能用.(如果能用能详细点吗?)2\如果用DBComboBox1的话, 它能够集成到TDBGrid中吗? 否则光标无法控制!