10 个解决方案
#1
双击表格,弹出一对话框,增加字段,在Picklist处加入你的选择项。
#2
DBGrid的Column有一个PickList的属性,是TStrings类型的,
你往PickList加入值就可以了,自然会有下拉列表框出现.
你往PickList加入值就可以了,自然会有下拉列表框出现.
#3
有两种值在列表框中显示的是一种字符型数据,实际存储的是数值型数据比如1-男,2-女要求在列表框中显示男,女而存储的是1,2。另外列表框中的数据想要来自于数据库而不是通过手输入的话,该如何来实现?如果不用LOOKUP字段用其它方法怎么能实现呢?
#4
up
#5
GZ
#6
无人能回答
#7
to xzgyb(回首往事,不堪回首) :
男。女所在的表是主表,还是明细表?
男。女所在的表是主表,还是明细表?
#8
应该是明细表但这有什么关系?
#9
一个例子:to sywxy(DELPHI的初学者):这个可以加dbcheckbox,dbcombobox,dblookupbox
----------unit-----------------
unit Gridmain;
interface
uses
SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
Forms, Dialogs, StdCtrls, DB, DBTables, DBLookup, Mask, DBCtrls,
ExtCtrls, Grids, DBGrids, Buttons, Calendar;
type
TForm1 = class(TForm)
TableGridData: TTable;
DataSourceGridData: TDataSource;
TableCust: TTable;
DataSourceCust: TDataSource;
DBNavigator1: TDBNavigator;
DBGrid1: TDBGrid;
TableGridDataOrderNo: TFloatField;
TableGridDataCustNo: TFloatField;
TableGridDataShipVIA: TStringField;
TableGridDataCheckBox: TBooleanField;
DBLookupCombo1: TDBLookupCombo;
DBCheckBox1: TDBCheckBox;
DBComboBox1: TDBComboBox;
ImageTrue: TImage;
ImageFalse: TImage;
Database1: TDatabase;
procedure FormCreate(Sender: TObject);
procedure DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect;
Field: TField; State: TGridDrawState);
procedure DBGrid1KeyPress(Sender: TObject; var Key: Char);
procedure DBCheckBox1Click(Sender: TObject);
procedure DBGrid1ColExit(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
Database1.Params.Add('Path='+ExtractFileDir(Application.EXEName));
Database1.Open;
TableGridData.Open;
DBLookupCombo1.Visible := False;
DBCheckBox1.Visible := False;
DBComboBox1.Visible := False;
ImageTrue.Visible := False;
ImageFalse.Visible := False;
end;
procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect;
Field: TField; State: TGridDrawState);
begin
{ If Field.Index = 4 then
DBGrid1.Canvas.FillRect(Rect); }
if (gdFocused in State) then
begin
if (Field.FieldName = DBLookupCombo1.DataField) then
begin
DBLookupCombo1.Left := Rect.Left + DBGrid1.Left;
DBLookupCombo1.Top := Rect.Top + DBGrid1.top;
DBLookupCombo1.Width := Rect.Right - Rect.Left;
DBLookupCombo1.Height := Rect.Bottom - Rect.Top;
DBLookupCombo1.Visible := True;
end
else if (Field.FieldName = DBCheckBox1.DataField) then
begin
DBCheckBox1.Left := Rect.Left + DBGrid1.Left + 1;
DBCheckBox1.Top := Rect.Top + DBGrid1.top + 1;
DBCheckBox1.Width := Rect.Right - Rect.Left{ - 1};
DBCheckBox1.Height := Rect.Bottom - Rect.Top{ - 1};
DBCheckBox1.Visible := True;
end
else 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
else {in this else area draw any stay behind bit maps}
begin
if (Field.FieldName = DBCheckBox1.DataField) then
begin
if TableGridDataCheckBox.AsBoolean then
DBGrid1.Canvas.Draw(Rect.Left,Rect.Top, ImageTrue.Picture.Bitmap)
else
DBGrid1.Canvas.Draw(Rect.Left,Rect.Top, ImageFalse.Picture.Bitmap)
{ DBGrid1.Canvas.StretchDraw(Rect, ImageFalse.Picture.Bitmap); }
end
{ Do bit map dwawing if you want}
{ DBGrid1.Canvas.FillRect(Rect); }
end;
end;
procedure TForm1.DBGrid1ColExit(Sender: TObject);
begin
If DBGrid1.SelectedField.FieldName = DBLookupCombo1.DataField then
DBLookupCombo1.Visible := false
else If DBGrid1.SelectedField.FieldName = DBCheckBox1.DataField then
DBCheckBox1.Visible := false
else If DBGrid1.SelectedField.FieldName = DBComboBox1.DataField then
DBComboBox1.Visible := false;
end;
procedure TForm1.DBGrid1KeyPress(Sender: TObject; var Key: Char);
begin
if (key <> chr(9)) then
begin
if (DBGrid1.SelectedField.FieldName = DBLookupCombo1.DataField) then
begin
DBLookupCombo1.SetFocus;
SendMessage(DBLookupCombo1.Handle, WM_Char, word(Key), 0);
end
else if (DBGrid1.SelectedField.FieldName = DBCheckBox1.DataField) then
begin
DBCheckBox1.SetFocus;
SendMessage(DBCheckBox1.Handle, WM_Char, word(Key), 0);
end
else if (DBGrid1.SelectedField.FieldName = DBComboBox1.DataField) then
begin
DBComboBox1.SetFocus;
SendMessage(DBComboBox1.Handle, WM_Char, word(Key), 0);
end;
end;
end;
procedure TForm1.DBCheckBox1Click(Sender: TObject);
begin
if SendMessage(DBCheckBox1.Handle, BM_GetCheck, 0, 0) = 0 then
DBCheckBox1.Caption := ' ' + 'False'
else
DBCheckBox1.Caption := ' ' + 'True'
end;
end.
//Notes > make sure to set the color of the checkbox to match the backgroung
------------------------------form------------------
object Form1: TForm1
Left = 119
Top = 111
BorderStyle = bsDialog
Caption = 'Form1'
ClientHeight = 434
ClientWidth = 468
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'System'
Font.Style = []
OldCreateOrder = True
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 16
object ImageTrue: TImage
Left = 214
Top = 316
Width = 84
Height = 19
Picture.Data = {
07544269746D6170720A0000424D720A00000000000036040000280000005400
00001300000001000800000000003C0600000000000000000000000100000000
000000000000000080000080000000808000800000008000800080800000C0C0
C000C0DCC000F0CAA60000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000F0FBFF00A4A0
A000808080000000FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFF
FF00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFF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FFFFFFFFFFF0000FFFFFFFF0000FFFFFF0000FF
FF0000FFFF0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFF800FFFFFF000000FFFFFF07FF07FFFFFFFFFFFFFFFFFF
FFFFFFFFFFFF0000FFFFFFFF0000FFFFFF0000FFFF0000FFFF000000000000FF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF800FF
FF0000000000FFFF07FF07FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000FFFFFFFF
000000FFFF0000FFFF0000FFFF0000FFFF0000FFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF800FF000000FF000000FF07FF07FF
FFFFFFFFFFFFFFFFFFFFFFFFFFFF0000FFFFFFFF00000000FF0000FFFF0000FF
FFFF00000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFF800FF0000FFFFFF0000FF07FF07FFFFFFFFFFFFFFFFFFFFFFFFFF
FFFF0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF800FFFFFFFFFF
FFFFFFFF07FF07FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000FFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFF80000000000000000000007FF07FFFFFFFFFF
FFFFFFFFFFFFFF0000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFF8F8F8F8F8F8F8F8F8F8F8F80707FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF}
end
object ImageFalse: TImage
Left = 217
Top = 283
Width = 85
Height = 20
Picture.Data = {
07544269746D6170720A0000424D720A00000000000036040000280000005400
00001300000001000800000000003C0600000000000000000000000100000000
000000000000000080000080000000808000800000008000800080800000C0C0
C000C0DCC000F0CAA60000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000F0FBFF00A4A0
A000808080000000FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFF
FF00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF07FFFFFFFFFFFFFFFFFFFFFFFF07
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFF80007070707070707070707FF07FFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF800FFFFFFFF
FFFFFFFFFF07FF07FFFFFFFFFFFFFFFFFFFFFFFFFF0000FFFFFFFFFFFFFF0000
000000FFFF0000FFFFFF00000000FFFFFFFF00000000FFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFF800FFFFFFFFFFFFFFFFFF07FF07FFFFFFFF
FFFFFFFFFFFFFFFFFF0000FFFFFFFFFFFF0000FFFF0000FFFF0000FFFF0000FF
FF0000FFFF0000FFFF0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFF800FFFFFFFFFFFFFFFFFF07FF07FFFFFFFFFFFFFFFFFFFFFFFFFF0000FF
FFFFFFFFFF0000FFFF0000FFFF0000FFFFFFFFFFFF0000FFFF0000FFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF800FFFFFFFFFFFFFFFF
FF07FF07FFFFFFFFFFFFFFFFFFFFFFFFFF0000FFFFFFFFFFFFFF0000FF0000FF
FF0000FFFFFF00000000FFFFFF0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFF800FFFFFFFFFFFFFFFFFF07FF07FFFFFFFFFFFFFFFF
FFFFFFFFFF0000FFFFFFFFFFFFFFFF00000000FFFF0000FFFF0000FFFFFFFFFF
FF000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF800
FFFFFFFFFFFFFFFFFF07FF07FFFFFFFFFFFFFFFFFFFFFFFFFF000000000000FF
FF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF800FFFFFFFFFFFFFFFFFF07FF07
FFFFFFFFFFFFFFFFFFFFFFFFFF0000FFFFFFFFFFFFFF00000000FFFFFF0000FF
FFFF00000000FFFFFFFF00000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFF800FFFFFFFFFFFFFFFFFF07FF07FFFFFFFFFFFFFFFFFFFFFFFF
FF0000FFFFFFFFFFFFFFFFFFFFFFFFFFFF0000FFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF800FFFFFFFF
FFFFFFFFFF07FF07FFFFFFFFFFFFFFFFFFFFFFFFFF0000FFFFFFFFFFFFFFFFFF
FFFFFFFFFF0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFF80000000000000000000007FF07FFFFFFFF
FFFFFFFFFFFFFFFFFF00000000000000FFFFFFFFFFFFFFFFFF0000FFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFF8F8F8F8F8F8F8F8F8F8F8F80707FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF}
end
object DBNavigator1: TDBNavigator
Left = 97
Top = 236
Width = 240
Height = 25
DataSource = DataSourceGridData
ParentShowHint = False
ShowHint = True
TabOrder = 0
end
object DBGrid1: TDBGrid
Left = 0
Top = 8
Width = 465
Height = 223
DataSource = DataSourceGridData
TabOrder = 1
TitleFont.Charset = DEFAULT_CHARSET
TitleFont.Color = clWindowText
TitleFont.Height = -13
TitleFont.Name = 'System'
TitleFont.Style = []
OnColExit = DBGrid1ColExit
OnDrawDataCell = DBGrid1DrawDataCell
OnKeyPress = DBGrid1KeyPress
end
object DBLookupCombo1: TDBLookupCombo
Left = 311
Top = 282
Width = 121
Height = 31
TabStop = False
DataField = 'CustNo'
DataSource = DataSourceGridData
LookupSource = DataSourceCust
LookupDisplay = 'Company'
LookupField = 'CustNo'
DropDownWidth = 200
TabOrder = 2
end
object DBCheckBox1: TDBCheckBox
Left = 114
Top = 285
Width = 90
Height = 17
TabStop = False
Alignment = taLeftJustify
Color = clBtnFace
DataField = 'CheckBox'
DataSource = DataSourceGridData
ParentColor = False
TabOrder = 3
ValueChecked = 'True'
ValueUnchecked = 'False'
OnClick = DBCheckBox1Click
end
object DBComboBox1: TDBComboBox
Left = 313
Top = 314
Width = 145
Height = 24
DataField = 'ShipVIA'
DataSource = DataSourceGridData
ItemHeight = 16
Items.Strings = (
'UPS'
'DHL'
'Emery'
'US Mail'
'FedEx')
TabOrder = 4
end
object TableGridData: TTable
DatabaseName = 'DemoGrid'
TableName = 'GRIDDATA.DB'
Left = 36
Top = 330
object TableGridDataOrderNo: TFloatField
DisplayWidth = 8
FieldName = 'OrderNo'
end
object TableGridDataCustNo: TFloatField
DisplayLabel = 'DBLookupCombo'
DisplayWidth = 18
FieldName = 'CustNo'
Required = True
end
object TableGridDataShipVIA: TStringField
DisplayLabel = 'DBCombo'
DisplayWidth = 13
FieldName = 'ShipVIA'
Size = 7
end
object TableGridDataCheckBox: TBooleanField
DisplayWidth = 10
FieldName = 'CheckBox'
end
end
object DataSourceGridData: TDataSource
DataSet = TableGridData
Left = 2
Top = 328
end
object TableCust: TTable
Active = True
DatabaseName = 'DBDEMOS'
TableName = 'CUSTOMER.DB'
Left = 34
Top = 292
end
object DataSourceCust: TDataSource
DataSet = TableCust
Left = 4
Top = 294
end
object Database1: TDatabase
DatabaseName = 'DemoGrid'
DriverName = 'STANDARD'
KeepConnection = False
LoginPrompt = False
Params.Strings = (
'DEFAULT DRIVER=PARADOX')
SessionName = 'Default'
Left = 72
Top = 296
end
end
----------unit-----------------
unit Gridmain;
interface
uses
SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
Forms, Dialogs, StdCtrls, DB, DBTables, DBLookup, Mask, DBCtrls,
ExtCtrls, Grids, DBGrids, Buttons, Calendar;
type
TForm1 = class(TForm)
TableGridData: TTable;
DataSourceGridData: TDataSource;
TableCust: TTable;
DataSourceCust: TDataSource;
DBNavigator1: TDBNavigator;
DBGrid1: TDBGrid;
TableGridDataOrderNo: TFloatField;
TableGridDataCustNo: TFloatField;
TableGridDataShipVIA: TStringField;
TableGridDataCheckBox: TBooleanField;
DBLookupCombo1: TDBLookupCombo;
DBCheckBox1: TDBCheckBox;
DBComboBox1: TDBComboBox;
ImageTrue: TImage;
ImageFalse: TImage;
Database1: TDatabase;
procedure FormCreate(Sender: TObject);
procedure DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect;
Field: TField; State: TGridDrawState);
procedure DBGrid1KeyPress(Sender: TObject; var Key: Char);
procedure DBCheckBox1Click(Sender: TObject);
procedure DBGrid1ColExit(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
Database1.Params.Add('Path='+ExtractFileDir(Application.EXEName));
Database1.Open;
TableGridData.Open;
DBLookupCombo1.Visible := False;
DBCheckBox1.Visible := False;
DBComboBox1.Visible := False;
ImageTrue.Visible := False;
ImageFalse.Visible := False;
end;
procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect;
Field: TField; State: TGridDrawState);
begin
{ If Field.Index = 4 then
DBGrid1.Canvas.FillRect(Rect); }
if (gdFocused in State) then
begin
if (Field.FieldName = DBLookupCombo1.DataField) then
begin
DBLookupCombo1.Left := Rect.Left + DBGrid1.Left;
DBLookupCombo1.Top := Rect.Top + DBGrid1.top;
DBLookupCombo1.Width := Rect.Right - Rect.Left;
DBLookupCombo1.Height := Rect.Bottom - Rect.Top;
DBLookupCombo1.Visible := True;
end
else if (Field.FieldName = DBCheckBox1.DataField) then
begin
DBCheckBox1.Left := Rect.Left + DBGrid1.Left + 1;
DBCheckBox1.Top := Rect.Top + DBGrid1.top + 1;
DBCheckBox1.Width := Rect.Right - Rect.Left{ - 1};
DBCheckBox1.Height := Rect.Bottom - Rect.Top{ - 1};
DBCheckBox1.Visible := True;
end
else 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
else {in this else area draw any stay behind bit maps}
begin
if (Field.FieldName = DBCheckBox1.DataField) then
begin
if TableGridDataCheckBox.AsBoolean then
DBGrid1.Canvas.Draw(Rect.Left,Rect.Top, ImageTrue.Picture.Bitmap)
else
DBGrid1.Canvas.Draw(Rect.Left,Rect.Top, ImageFalse.Picture.Bitmap)
{ DBGrid1.Canvas.StretchDraw(Rect, ImageFalse.Picture.Bitmap); }
end
{ Do bit map dwawing if you want}
{ DBGrid1.Canvas.FillRect(Rect); }
end;
end;
procedure TForm1.DBGrid1ColExit(Sender: TObject);
begin
If DBGrid1.SelectedField.FieldName = DBLookupCombo1.DataField then
DBLookupCombo1.Visible := false
else If DBGrid1.SelectedField.FieldName = DBCheckBox1.DataField then
DBCheckBox1.Visible := false
else If DBGrid1.SelectedField.FieldName = DBComboBox1.DataField then
DBComboBox1.Visible := false;
end;
procedure TForm1.DBGrid1KeyPress(Sender: TObject; var Key: Char);
begin
if (key <> chr(9)) then
begin
if (DBGrid1.SelectedField.FieldName = DBLookupCombo1.DataField) then
begin
DBLookupCombo1.SetFocus;
SendMessage(DBLookupCombo1.Handle, WM_Char, word(Key), 0);
end
else if (DBGrid1.SelectedField.FieldName = DBCheckBox1.DataField) then
begin
DBCheckBox1.SetFocus;
SendMessage(DBCheckBox1.Handle, WM_Char, word(Key), 0);
end
else if (DBGrid1.SelectedField.FieldName = DBComboBox1.DataField) then
begin
DBComboBox1.SetFocus;
SendMessage(DBComboBox1.Handle, WM_Char, word(Key), 0);
end;
end;
end;
procedure TForm1.DBCheckBox1Click(Sender: TObject);
begin
if SendMessage(DBCheckBox1.Handle, BM_GetCheck, 0, 0) = 0 then
DBCheckBox1.Caption := ' ' + 'False'
else
DBCheckBox1.Caption := ' ' + 'True'
end;
end.
//Notes > make sure to set the color of the checkbox to match the backgroung
------------------------------form------------------
object Form1: TForm1
Left = 119
Top = 111
BorderStyle = bsDialog
Caption = 'Form1'
ClientHeight = 434
ClientWidth = 468
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'System'
Font.Style = []
OldCreateOrder = True
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 16
object ImageTrue: TImage
Left = 214
Top = 316
Width = 84
Height = 19
Picture.Data = {
07544269746D6170720A0000424D720A00000000000036040000280000005400
00001300000001000800000000003C0600000000000000000000000100000000
000000000000000080000080000000808000800000008000800080800000C0C0
C000C0DCC000F0CAA60000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000F0FBFF00A4A0
A000808080000000FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFF
FF00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF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FFFFFF0000FFFFFF0000FFFF0000FFFF0000FF
FF0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFF800FF000000FF000000FF07FF07FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000
FFFFFFFF0000FFFFFF0000FFFF0000FFFF0000FFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF800FFFF0000000000FFFF
07FF07FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000FFFFFFFF0000FFFFFF0000FF
FF0000FFFF0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFF800FFFFFF000000FFFFFF07FF07FFFFFFFFFFFFFFFFFF
FFFFFFFFFFFF0000FFFFFFFF0000FFFFFF0000FFFF0000FFFF000000000000FF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF800FF
FF0000000000FFFF07FF07FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000FFFFFFFF
000000FFFF0000FFFF0000FFFF0000FFFF0000FFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF800FF000000FF000000FF07FF07FF
FFFFFFFFFFFFFFFFFFFFFFFFFFFF0000FFFFFFFF00000000FF0000FFFF0000FF
FFFF00000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFF800FF0000FFFFFF0000FF07FF07FFFFFFFFFFFFFFFFFFFFFFFFFF
FFFF0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF800FFFFFFFFFF
FFFFFFFF07FF07FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000FFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFF80000000000000000000007FF07FFFFFFFFFF
FFFFFFFFFFFFFF0000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFF8F8F8F8F8F8F8F8F8F8F8F80707FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF}
end
object ImageFalse: TImage
Left = 217
Top = 283
Width = 85
Height = 20
Picture.Data = {
07544269746D6170720A0000424D720A00000000000036040000280000005400
00001300000001000800000000003C0600000000000000000000000100000000
000000000000000080000080000000808000800000008000800080800000C0C0
C000C0DCC000F0CAA60000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000F0FBFF00A4A0
A000808080000000FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFF
FF00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFF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FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF800FFFFFFFFFFFFFFFF
FF07FF07FFFFFFFFFFFFFFFFFFFFFFFFFF0000FFFFFFFFFFFFFF0000FF0000FF
FF0000FFFFFF00000000FFFFFF0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFF800FFFFFFFFFFFFFFFFFF07FF07FFFFFFFFFFFFFFFF
FFFFFFFFFF0000FFFFFFFFFFFFFFFF00000000FFFF0000FFFF0000FFFFFFFFFF
FF000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF800
FFFFFFFFFFFFFFFFFF07FF07FFFFFFFFFFFFFFFFFFFFFFFFFF000000000000FF
FF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF800FFFFFFFFFFFFFFFFFF07FF07
FFFFFFFFFFFFFFFFFFFFFFFFFF0000FFFFFFFFFFFFFF00000000FFFFFF0000FF
FFFF00000000FFFFFFFF00000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFF800FFFFFFFFFFFFFFFFFF07FF07FFFFFFFFFFFFFFFFFFFFFFFF
FF0000FFFFFFFFFFFFFFFFFFFFFFFFFFFF0000FFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF800FFFFFFFF
FFFFFFFFFF07FF07FFFFFFFFFFFFFFFFFFFFFFFFFF0000FFFFFFFFFFFFFFFFFF
FFFFFFFFFF0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFF80000000000000000000007FF07FFFFFFFF
FFFFFFFFFFFFFFFFFF00000000000000FFFFFFFFFFFFFFFFFF0000FFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFF8F8F8F8F8F8F8F8F8F8F8F80707FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF}
end
object DBNavigator1: TDBNavigator
Left = 97
Top = 236
Width = 240
Height = 25
DataSource = DataSourceGridData
ParentShowHint = False
ShowHint = True
TabOrder = 0
end
object DBGrid1: TDBGrid
Left = 0
Top = 8
Width = 465
Height = 223
DataSource = DataSourceGridData
TabOrder = 1
TitleFont.Charset = DEFAULT_CHARSET
TitleFont.Color = clWindowText
TitleFont.Height = -13
TitleFont.Name = 'System'
TitleFont.Style = []
OnColExit = DBGrid1ColExit
OnDrawDataCell = DBGrid1DrawDataCell
OnKeyPress = DBGrid1KeyPress
end
object DBLookupCombo1: TDBLookupCombo
Left = 311
Top = 282
Width = 121
Height = 31
TabStop = False
DataField = 'CustNo'
DataSource = DataSourceGridData
LookupSource = DataSourceCust
LookupDisplay = 'Company'
LookupField = 'CustNo'
DropDownWidth = 200
TabOrder = 2
end
object DBCheckBox1: TDBCheckBox
Left = 114
Top = 285
Width = 90
Height = 17
TabStop = False
Alignment = taLeftJustify
Color = clBtnFace
DataField = 'CheckBox'
DataSource = DataSourceGridData
ParentColor = False
TabOrder = 3
ValueChecked = 'True'
ValueUnchecked = 'False'
OnClick = DBCheckBox1Click
end
object DBComboBox1: TDBComboBox
Left = 313
Top = 314
Width = 145
Height = 24
DataField = 'ShipVIA'
DataSource = DataSourceGridData
ItemHeight = 16
Items.Strings = (
'UPS'
'DHL'
'Emery'
'US Mail'
'FedEx')
TabOrder = 4
end
object TableGridData: TTable
DatabaseName = 'DemoGrid'
TableName = 'GRIDDATA.DB'
Left = 36
Top = 330
object TableGridDataOrderNo: TFloatField
DisplayWidth = 8
FieldName = 'OrderNo'
end
object TableGridDataCustNo: TFloatField
DisplayLabel = 'DBLookupCombo'
DisplayWidth = 18
FieldName = 'CustNo'
Required = True
end
object TableGridDataShipVIA: TStringField
DisplayLabel = 'DBCombo'
DisplayWidth = 13
FieldName = 'ShipVIA'
Size = 7
end
object TableGridDataCheckBox: TBooleanField
DisplayWidth = 10
FieldName = 'CheckBox'
end
end
object DataSourceGridData: TDataSource
DataSet = TableGridData
Left = 2
Top = 328
end
object TableCust: TTable
Active = True
DatabaseName = 'DBDEMOS'
TableName = 'CUSTOMER.DB'
Left = 34
Top = 292
end
object DataSourceCust: TDataSource
DataSet = TableCust
Left = 4
Top = 294
end
object Database1: TDatabase
DatabaseName = 'DemoGrid'
DriverName = 'STANDARD'
KeepConnection = False
LoginPrompt = False
Params.Strings = (
'DEFAULT DRIVER=PARADOX')
SessionName = 'Default'
Left = 72
Top = 296
end
end
#10
这个例子太复杂了,老哥有没有实例呀,发到我的信箱 microrain@cmmail.com
#1
双击表格,弹出一对话框,增加字段,在Picklist处加入你的选择项。
#2
DBGrid的Column有一个PickList的属性,是TStrings类型的,
你往PickList加入值就可以了,自然会有下拉列表框出现.
你往PickList加入值就可以了,自然会有下拉列表框出现.
#3
有两种值在列表框中显示的是一种字符型数据,实际存储的是数值型数据比如1-男,2-女要求在列表框中显示男,女而存储的是1,2。另外列表框中的数据想要来自于数据库而不是通过手输入的话,该如何来实现?如果不用LOOKUP字段用其它方法怎么能实现呢?
#4
up
#5
GZ
#6
无人能回答
#7
to xzgyb(回首往事,不堪回首) :
男。女所在的表是主表,还是明细表?
男。女所在的表是主表,还是明细表?
#8
应该是明细表但这有什么关系?
#9
一个例子:to sywxy(DELPHI的初学者):这个可以加dbcheckbox,dbcombobox,dblookupbox
----------unit-----------------
unit Gridmain;
interface
uses
SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
Forms, Dialogs, StdCtrls, DB, DBTables, DBLookup, Mask, DBCtrls,
ExtCtrls, Grids, DBGrids, Buttons, Calendar;
type
TForm1 = class(TForm)
TableGridData: TTable;
DataSourceGridData: TDataSource;
TableCust: TTable;
DataSourceCust: TDataSource;
DBNavigator1: TDBNavigator;
DBGrid1: TDBGrid;
TableGridDataOrderNo: TFloatField;
TableGridDataCustNo: TFloatField;
TableGridDataShipVIA: TStringField;
TableGridDataCheckBox: TBooleanField;
DBLookupCombo1: TDBLookupCombo;
DBCheckBox1: TDBCheckBox;
DBComboBox1: TDBComboBox;
ImageTrue: TImage;
ImageFalse: TImage;
Database1: TDatabase;
procedure FormCreate(Sender: TObject);
procedure DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect;
Field: TField; State: TGridDrawState);
procedure DBGrid1KeyPress(Sender: TObject; var Key: Char);
procedure DBCheckBox1Click(Sender: TObject);
procedure DBGrid1ColExit(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
Database1.Params.Add('Path='+ExtractFileDir(Application.EXEName));
Database1.Open;
TableGridData.Open;
DBLookupCombo1.Visible := False;
DBCheckBox1.Visible := False;
DBComboBox1.Visible := False;
ImageTrue.Visible := False;
ImageFalse.Visible := False;
end;
procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect;
Field: TField; State: TGridDrawState);
begin
{ If Field.Index = 4 then
DBGrid1.Canvas.FillRect(Rect); }
if (gdFocused in State) then
begin
if (Field.FieldName = DBLookupCombo1.DataField) then
begin
DBLookupCombo1.Left := Rect.Left + DBGrid1.Left;
DBLookupCombo1.Top := Rect.Top + DBGrid1.top;
DBLookupCombo1.Width := Rect.Right - Rect.Left;
DBLookupCombo1.Height := Rect.Bottom - Rect.Top;
DBLookupCombo1.Visible := True;
end
else if (Field.FieldName = DBCheckBox1.DataField) then
begin
DBCheckBox1.Left := Rect.Left + DBGrid1.Left + 1;
DBCheckBox1.Top := Rect.Top + DBGrid1.top + 1;
DBCheckBox1.Width := Rect.Right - Rect.Left{ - 1};
DBCheckBox1.Height := Rect.Bottom - Rect.Top{ - 1};
DBCheckBox1.Visible := True;
end
else 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
else {in this else area draw any stay behind bit maps}
begin
if (Field.FieldName = DBCheckBox1.DataField) then
begin
if TableGridDataCheckBox.AsBoolean then
DBGrid1.Canvas.Draw(Rect.Left,Rect.Top, ImageTrue.Picture.Bitmap)
else
DBGrid1.Canvas.Draw(Rect.Left,Rect.Top, ImageFalse.Picture.Bitmap)
{ DBGrid1.Canvas.StretchDraw(Rect, ImageFalse.Picture.Bitmap); }
end
{ Do bit map dwawing if you want}
{ DBGrid1.Canvas.FillRect(Rect); }
end;
end;
procedure TForm1.DBGrid1ColExit(Sender: TObject);
begin
If DBGrid1.SelectedField.FieldName = DBLookupCombo1.DataField then
DBLookupCombo1.Visible := false
else If DBGrid1.SelectedField.FieldName = DBCheckBox1.DataField then
DBCheckBox1.Visible := false
else If DBGrid1.SelectedField.FieldName = DBComboBox1.DataField then
DBComboBox1.Visible := false;
end;
procedure TForm1.DBGrid1KeyPress(Sender: TObject; var Key: Char);
begin
if (key <> chr(9)) then
begin
if (DBGrid1.SelectedField.FieldName = DBLookupCombo1.DataField) then
begin
DBLookupCombo1.SetFocus;
SendMessage(DBLookupCombo1.Handle, WM_Char, word(Key), 0);
end
else if (DBGrid1.SelectedField.FieldName = DBCheckBox1.DataField) then
begin
DBCheckBox1.SetFocus;
SendMessage(DBCheckBox1.Handle, WM_Char, word(Key), 0);
end
else if (DBGrid1.SelectedField.FieldName = DBComboBox1.DataField) then
begin
DBComboBox1.SetFocus;
SendMessage(DBComboBox1.Handle, WM_Char, word(Key), 0);
end;
end;
end;
procedure TForm1.DBCheckBox1Click(Sender: TObject);
begin
if SendMessage(DBCheckBox1.Handle, BM_GetCheck, 0, 0) = 0 then
DBCheckBox1.Caption := ' ' + 'False'
else
DBCheckBox1.Caption := ' ' + 'True'
end;
end.
//Notes > make sure to set the color of the checkbox to match the backgroung
------------------------------form------------------
object Form1: TForm1
Left = 119
Top = 111
BorderStyle = bsDialog
Caption = 'Form1'
ClientHeight = 434
ClientWidth = 468
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'System'
Font.Style = []
OldCreateOrder = True
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 16
object ImageTrue: TImage
Left = 214
Top = 316
Width = 84
Height = 19
Picture.Data = {
07544269746D6170720A0000424D720A00000000000036040000280000005400
00001300000001000800000000003C0600000000000000000000000100000000
000000000000000080000080000000808000800000008000800080800000C0C0
C000C0DCC000F0CAA60000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000F0FBFF00A4A0
A000808080000000FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFF
FF00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF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F0000FFFFFF0000FF
FF0000FFFF0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFF800FFFFFF000000FFFFFF07FF07FFFFFFFFFFFFFFFFFF
FFFFFFFFFFFF0000FFFFFFFF0000FFFFFF0000FFFF0000FFFF000000000000FF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF800FF
FF0000000000FFFF07FF07FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000FFFFFFFF
000000FFFF0000FFFF0000FFFF0000FFFF0000FFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF800FF000000FF000000FF07FF07FF
FFFFFFFFFFFFFFFFFFFFFFFFFFFF0000FFFFFFFF00000000FF0000FFFF0000FF
FFFF00000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFF800FF0000FFFFFF0000FF07FF07FFFFFFFFFFFFFFFFFFFFFFFFFF
FFFF0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF800FFFFFFFFFF
FFFFFFFF07FF07FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000FFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFF80000000000000000000007FF07FFFFFFFFFF
FFFFFFFFFFFFFF0000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFF8F8F8F8F8F8F8F8F8F8F8F80707FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF}
end
object ImageFalse: TImage
Left = 217
Top = 283
Width = 85
Height = 20
Picture.Data = {
07544269746D6170720A0000424D720A00000000000036040000280000005400
00001300000001000800000000003C0600000000000000000000000100000000
000000000000000080000080000000808000800000008000800080800000C0C0
C000C0DCC000F0CAA60000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000F0FBFF00A4A0
A000808080000000FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFF
FF00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF07FFFFFFFFFFFFFFFFFFFFFFFF07
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFF80007070707070707070707FF07FFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF800FFFFFFFF
FFFFFFFFFF07FF07FFFFFFFFFFFFFFFFFFFFFFFFFF0000FFFFFFFFFFFFFF0000
000000FFFF0000FFFFFF00000000FFFFFFFF00000000FFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFF800FFFFFFFFFFFFFFFFFF07FF07FFFFFFFF
FFFFFFFFFFFFFFFFFF0000FFFFFFFFFFFF0000FFFF0000FFFF0000FFFF0000FF
FF0000FFFF0000FFFF0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFF800FFFFFFFFFFFFFFFFFF07FF07FFFFFFFFFFFFFFFFFFFFFFFFFF0000FF
FFFFFFFFFF0000FFFF0000FFFF0000FFFFFFFFFFFF0000FFFF0000FFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF800FFFFFFFFFFFFFFFF
FF07FF07FFFFFFFFFFFFFFFFFFFFFFFFFF0000FFFFFFFFFFFFFF0000FF0000FF
FF0000FFFFFF00000000FFFFFF0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFF800FFFFFFFFFFFFFFFFFF07FF07FFFFFFFFFFFFFFFF
FFFFFFFFFF0000FFFFFFFFFFFFFFFF00000000FFFF0000FFFF0000FFFFFFFFFF
FF000000000000FFFFF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FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF}
end
object DBNavigator1: TDBNavigator
Left = 97
Top = 236
Width = 240
Height = 25
DataSource = DataSourceGridData
ParentShowHint = False
ShowHint = True
TabOrder = 0
end
object DBGrid1: TDBGrid
Left = 0
Top = 8
Width = 465
Height = 223
DataSource = DataSourceGridData
TabOrder = 1
TitleFont.Charset = DEFAULT_CHARSET
TitleFont.Color = clWindowText
TitleFont.Height = -13
TitleFont.Name = 'System'
TitleFont.Style = []
OnColExit = DBGrid1ColExit
OnDrawDataCell = DBGrid1DrawDataCell
OnKeyPress = DBGrid1KeyPress
end
object DBLookupCombo1: TDBLookupCombo
Left = 311
Top = 282
Width = 121
Height = 31
TabStop = False
DataField = 'CustNo'
DataSource = DataSourceGridData
LookupSource = DataSourceCust
LookupDisplay = 'Company'
LookupField = 'CustNo'
DropDownWidth = 200
TabOrder = 2
end
object DBCheckBox1: TDBCheckBox
Left = 114
Top = 285
Width = 90
Height = 17
TabStop = False
Alignment = taLeftJustify
Color = clBtnFace
DataField = 'CheckBox'
DataSource = DataSourceGridData
ParentColor = False
TabOrder = 3
ValueChecked = 'True'
ValueUnchecked = 'False'
OnClick = DBCheckBox1Click
end
object DBComboBox1: TDBComboBox
Left = 313
Top = 314
Width = 145
Height = 24
DataField = 'ShipVIA'
DataSource = DataSourceGridData
ItemHeight = 16
Items.Strings = (
'UPS'
'DHL'
'Emery'
'US Mail'
'FedEx')
TabOrder = 4
end
object TableGridData: TTable
DatabaseName = 'DemoGrid'
TableName = 'GRIDDATA.DB'
Left = 36
Top = 330
object TableGridDataOrderNo: TFloatField
DisplayWidth = 8
FieldName = 'OrderNo'
end
object TableGridDataCustNo: TFloatField
DisplayLabel = 'DBLookupCombo'
DisplayWidth = 18
FieldName = 'CustNo'
Required = True
end
object TableGridDataShipVIA: TStringField
DisplayLabel = 'DBCombo'
DisplayWidth = 13
FieldName = 'ShipVIA'
Size = 7
end
object TableGridDataCheckBox: TBooleanField
DisplayWidth = 10
FieldName = 'CheckBox'
end
end
object DataSourceGridData: TDataSource
DataSet = TableGridData
Left = 2
Top = 328
end
object TableCust: TTable
Active = True
DatabaseName = 'DBDEMOS'
TableName = 'CUSTOMER.DB'
Left = 34
Top = 292
end
object DataSourceCust: TDataSource
DataSet = TableCust
Left = 4
Top = 294
end
object Database1: TDatabase
DatabaseName = 'DemoGrid'
DriverName = 'STANDARD'
KeepConnection = False
LoginPrompt = False
Params.Strings = (
'DEFAULT DRIVER=PARADOX')
SessionName = 'Default'
Left = 72
Top = 296
end
end
----------unit-----------------
unit Gridmain;
interface
uses
SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
Forms, Dialogs, StdCtrls, DB, DBTables, DBLookup, Mask, DBCtrls,
ExtCtrls, Grids, DBGrids, Buttons, Calendar;
type
TForm1 = class(TForm)
TableGridData: TTable;
DataSourceGridData: TDataSource;
TableCust: TTable;
DataSourceCust: TDataSource;
DBNavigator1: TDBNavigator;
DBGrid1: TDBGrid;
TableGridDataOrderNo: TFloatField;
TableGridDataCustNo: TFloatField;
TableGridDataShipVIA: TStringField;
TableGridDataCheckBox: TBooleanField;
DBLookupCombo1: TDBLookupCombo;
DBCheckBox1: TDBCheckBox;
DBComboBox1: TDBComboBox;
ImageTrue: TImage;
ImageFalse: TImage;
Database1: TDatabase;
procedure FormCreate(Sender: TObject);
procedure DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect;
Field: TField; State: TGridDrawState);
procedure DBGrid1KeyPress(Sender: TObject; var Key: Char);
procedure DBCheckBox1Click(Sender: TObject);
procedure DBGrid1ColExit(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
Database1.Params.Add('Path='+ExtractFileDir(Application.EXEName));
Database1.Open;
TableGridData.Open;
DBLookupCombo1.Visible := False;
DBCheckBox1.Visible := False;
DBComboBox1.Visible := False;
ImageTrue.Visible := False;
ImageFalse.Visible := False;
end;
procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect;
Field: TField; State: TGridDrawState);
begin
{ If Field.Index = 4 then
DBGrid1.Canvas.FillRect(Rect); }
if (gdFocused in State) then
begin
if (Field.FieldName = DBLookupCombo1.DataField) then
begin
DBLookupCombo1.Left := Rect.Left + DBGrid1.Left;
DBLookupCombo1.Top := Rect.Top + DBGrid1.top;
DBLookupCombo1.Width := Rect.Right - Rect.Left;
DBLookupCombo1.Height := Rect.Bottom - Rect.Top;
DBLookupCombo1.Visible := True;
end
else if (Field.FieldName = DBCheckBox1.DataField) then
begin
DBCheckBox1.Left := Rect.Left + DBGrid1.Left + 1;
DBCheckBox1.Top := Rect.Top + DBGrid1.top + 1;
DBCheckBox1.Width := Rect.Right - Rect.Left{ - 1};
DBCheckBox1.Height := Rect.Bottom - Rect.Top{ - 1};
DBCheckBox1.Visible := True;
end
else 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
else {in this else area draw any stay behind bit maps}
begin
if (Field.FieldName = DBCheckBox1.DataField) then
begin
if TableGridDataCheckBox.AsBoolean then
DBGrid1.Canvas.Draw(Rect.Left,Rect.Top, ImageTrue.Picture.Bitmap)
else
DBGrid1.Canvas.Draw(Rect.Left,Rect.Top, ImageFalse.Picture.Bitmap)
{ DBGrid1.Canvas.StretchDraw(Rect, ImageFalse.Picture.Bitmap); }
end
{ Do bit map dwawing if you want}
{ DBGrid1.Canvas.FillRect(Rect); }
end;
end;
procedure TForm1.DBGrid1ColExit(Sender: TObject);
begin
If DBGrid1.SelectedField.FieldName = DBLookupCombo1.DataField then
DBLookupCombo1.Visible := false
else If DBGrid1.SelectedField.FieldName = DBCheckBox1.DataField then
DBCheckBox1.Visible := false
else If DBGrid1.SelectedField.FieldName = DBComboBox1.DataField then
DBComboBox1.Visible := false;
end;
procedure TForm1.DBGrid1KeyPress(Sender: TObject; var Key: Char);
begin
if (key <> chr(9)) then
begin
if (DBGrid1.SelectedField.FieldName = DBLookupCombo1.DataField) then
begin
DBLookupCombo1.SetFocus;
SendMessage(DBLookupCombo1.Handle, WM_Char, word(Key), 0);
end
else if (DBGrid1.SelectedField.FieldName = DBCheckBox1.DataField) then
begin
DBCheckBox1.SetFocus;
SendMessage(DBCheckBox1.Handle, WM_Char, word(Key), 0);
end
else if (DBGrid1.SelectedField.FieldName = DBComboBox1.DataField) then
begin
DBComboBox1.SetFocus;
SendMessage(DBComboBox1.Handle, WM_Char, word(Key), 0);
end;
end;
end;
procedure TForm1.DBCheckBox1Click(Sender: TObject);
begin
if SendMessage(DBCheckBox1.Handle, BM_GetCheck, 0, 0) = 0 then
DBCheckBox1.Caption := ' ' + 'False'
else
DBCheckBox1.Caption := ' ' + 'True'
end;
end.
//Notes > make sure to set the color of the checkbox to match the backgroung
------------------------------form------------------
object Form1: TForm1
Left = 119
Top = 111
BorderStyle = bsDialog
Caption = 'Form1'
ClientHeight = 434
ClientWidth = 468
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'System'
Font.Style = []
OldCreateOrder = True
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 16
object ImageTrue: TImage
Left = 214
Top = 316
Width = 84
Height = 19
Picture.Data = {
07544269746D6170720A0000424D720A00000000000036040000280000005400
00001300000001000800000000003C0600000000000000000000000100000000
000000000000000080000080000000808000800000008000800080800000C0C0
C000C0DCC000F0CAA60000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000F0FBFF00A4A0
A000808080000000FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFF
FF00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFF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0000FFFF0000FF
FF0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFF800FF000000FF000000FF07FF07FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000
FFFFFFFF0000FFFFFF0000FFFF0000FFFF0000FFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF800FFFF0000000000FFFF
07FF07FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000FFFFFFFF0000FFFFFF0000FF
FF0000FFFF0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFF800FFFFFF000000FFFFFF07FF07FFFFFFFFFFFFFFFFFF
FFFFFFFFFFFF0000FFFFFFFF0000FFFFFF0000FFFF0000FFFF000000000000FF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF800FF
FF0000000000FFFF07FF07FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000FFFFFFFF
000000FFFF0000FFFF0000FFFF0000FFFF0000FFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF800FF000000FF000000FF07FF07FF
FFFFFFFFFFFFFFFFFFFFFFFFFFFF0000FFFFFFFF00000000FF0000FFFF0000FF
FFFF00000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFF800FF0000FFFFFF0000FF07FF07FFFFFFFFFFFFFFFFFFFFFFFFFF
FFFF0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF800FFFFFFFFFF
FFFFFFFF07FF07FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000FFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFF80000000000000000000007FF07FFFFFFFFFF
FFFFFFFFFFFFFF0000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFF8F8F8F8F8F8F8F8F8F8F8F80707FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF}
end
object ImageFalse: TImage
Left = 217
Top = 283
Width = 85
Height = 20
Picture.Data = {
07544269746D6170720A0000424D720A00000000000036040000280000005400
00001300000001000800000000003C0600000000000000000000000100000000
000000000000000080000080000000808000800000008000800080800000C0C0
C000C0DCC000F0CAA60000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000F0FBFF00A4A0
A000808080000000FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFF
FF00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFF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FFFFFFFFFFFFFFFFFFFFFFFFF800FFFFFFFFFFFFFFFF
FF07FF07FFFFFFFFFFFFFFFFFFFFFFFFFF0000FFFFFFFFFFFFFF0000FF0000FF
FF0000FFFFFF00000000FFFFFF0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFF800FFFFFFFFFFFFFFFFFF07FF07FFFFFFFFFFFFFFFF
FFFFFFFFFF0000FFFFFFFFFFFFFFFF00000000FFFF0000FFFF0000FFFFFFFFFF
FF000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF800
FFFFFFFFFFFFFFFFFF07FF07FFFFFFFFFFFFFFFFFFFFFFFFFF000000000000FF
FF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF800FFFFFFFFFFFFFFFFFF07FF07
FFFFFFFFFFFFFFFFFFFFFFFFFF0000FFFFFFFFFFFFFF00000000FFFFFF0000FF
FFFF00000000FFFFFFFF00000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFF800FFFFFFFFFFFFFFFFFF07FF07FFFFFFFFFFFFFFFFFFFFFFFF
FF0000FFFFFFFFFFFFFFFFFFFFFFFFFFFF0000FFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF800FFFFFFFF
FFFFFFFFFF07FF07FFFFFFFFFFFFFFFFFFFFFFFFFF0000FFFFFFFFFFFFFFFFFF
FFFFFFFFFF0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFF80000000000000000000007FF07FFFFFFFF
FFFFFFFFFFFFFFFFFF00000000000000FFFFFFFFFFFFFFFFFF0000FFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFF8F8F8F8F8F8F8F8F8F8F8F80707FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF}
end
object DBNavigator1: TDBNavigator
Left = 97
Top = 236
Width = 240
Height = 25
DataSource = DataSourceGridData
ParentShowHint = False
ShowHint = True
TabOrder = 0
end
object DBGrid1: TDBGrid
Left = 0
Top = 8
Width = 465
Height = 223
DataSource = DataSourceGridData
TabOrder = 1
TitleFont.Charset = DEFAULT_CHARSET
TitleFont.Color = clWindowText
TitleFont.Height = -13
TitleFont.Name = 'System'
TitleFont.Style = []
OnColExit = DBGrid1ColExit
OnDrawDataCell = DBGrid1DrawDataCell
OnKeyPress = DBGrid1KeyPress
end
object DBLookupCombo1: TDBLookupCombo
Left = 311
Top = 282
Width = 121
Height = 31
TabStop = False
DataField = 'CustNo'
DataSource = DataSourceGridData
LookupSource = DataSourceCust
LookupDisplay = 'Company'
LookupField = 'CustNo'
DropDownWidth = 200
TabOrder = 2
end
object DBCheckBox1: TDBCheckBox
Left = 114
Top = 285
Width = 90
Height = 17
TabStop = False
Alignment = taLeftJustify
Color = clBtnFace
DataField = 'CheckBox'
DataSource = DataSourceGridData
ParentColor = False
TabOrder = 3
ValueChecked = 'True'
ValueUnchecked = 'False'
OnClick = DBCheckBox1Click
end
object DBComboBox1: TDBComboBox
Left = 313
Top = 314
Width = 145
Height = 24
DataField = 'ShipVIA'
DataSource = DataSourceGridData
ItemHeight = 16
Items.Strings = (
'UPS'
'DHL'
'Emery'
'US Mail'
'FedEx')
TabOrder = 4
end
object TableGridData: TTable
DatabaseName = 'DemoGrid'
TableName = 'GRIDDATA.DB'
Left = 36
Top = 330
object TableGridDataOrderNo: TFloatField
DisplayWidth = 8
FieldName = 'OrderNo'
end
object TableGridDataCustNo: TFloatField
DisplayLabel = 'DBLookupCombo'
DisplayWidth = 18
FieldName = 'CustNo'
Required = True
end
object TableGridDataShipVIA: TStringField
DisplayLabel = 'DBCombo'
DisplayWidth = 13
FieldName = 'ShipVIA'
Size = 7
end
object TableGridDataCheckBox: TBooleanField
DisplayWidth = 10
FieldName = 'CheckBox'
end
end
object DataSourceGridData: TDataSource
DataSet = TableGridData
Left = 2
Top = 328
end
object TableCust: TTable
Active = True
DatabaseName = 'DBDEMOS'
TableName = 'CUSTOMER.DB'
Left = 34
Top = 292
end
object DataSourceCust: TDataSource
DataSet = TableCust
Left = 4
Top = 294
end
object Database1: TDatabase
DatabaseName = 'DemoGrid'
DriverName = 'STANDARD'
KeepConnection = False
LoginPrompt = False
Params.Strings = (
'DEFAULT DRIVER=PARADOX')
SessionName = 'Default'
Left = 72
Top = 296
end
end
#10
这个例子太复杂了,老哥有没有实例呀,发到我的信箱 microrain@cmmail.com