其他分享
首页 > 其他分享> > dbgrideh中的keylist,picklist的用法

dbgrideh中的keylist,picklist的用法

作者:互联网

dbgrideh中的keylist,picklist的⽤法
dbgrideh
procedure TForm1.FormCreate(Sender: TObject);
begin
DBGridEh1.DataSource:=DataSource1;
DataSource1.DataSet:=MemTableEh1;
MemTableEh1.DataDriver:=DataSetDriverEh1;
MemTableEh1.FetchAllOnOpen:=True;
DataSetDriverEh1.ProviderDataSet:=ADOQuery1;
ADOQuery1.ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;'+ 'Data Source=f:\mcmygs.mdb;'+
'Persist Security Info=False;'+
'Jet OLEDB:Database Password=123456';
ADOQuery1.Close;
ADOQuery1.SQL.Text:='Select ⾃编号,合同号,币种,⾦额 from dzb'; ADOQuery1.Open;
MemTableEh1.Active:=True;
DBGridEh1.Flat:=True; //平⾯
DBGridEh1.TitleHeight:=20; //标题栏⾏⾼
DBGridEh1.OptionsEh:=DBGridEh1.OptionsEh+[dghShowRecNo]; //显⽰序号
DBGridEh1.ColumnDefValues.AlwaysShowEditButton:=True; //显⽰DropDowm图标
DBGridEh1.Columns[2].ImageList:=ImageList1;
DBGridEh1.Columns[2].ShowImageAndText:=True;
//PickList为显⽰出来的值,与ImageList中的图标顺序相对应
DBGridEh1.Columns[2].PickList.Add('美元');
DBGridEh1.Columns[2].PickList.Add('欧元');
DBGridEh1.Columns[2].PickList.Add('港币');
DBGridEh1.Columns[2].PickList.Add('⽇元');
DBGridEh1.Columns[2].PickList.Add('韩元');
//KeyList为数据库表中实际储存值,与PickList中值设置好相对应
DBGridEh1.Columns[2].KeyList.Add('USD');
DBGridEh1.Columns[2].KeyList.Add('EUR');
DBGridEh1.Columns[2].KeyList.Add('HKD');
DBGridEh1.Columns[2].KeyList.Add('JPY');
DBGridEh1.Columns[2].KeyList.Add('KRW');
DBGridEh1.Columns[2].Width:=80;
dbgrideh中的keylist,picklist的⽤法
dbgrideh
procedure TForm1.FormCreate(Sender: TObject);
begin
DBGridEh1.DataSource:=DataSource1;
DataSource1.DataSet:=MemTableEh1;
MemTableEh1.DataDriver:=DataSetDriverEh1;
MemTableEh1.FetchAllOnOpen:=True;
DataSetDriverEh1.ProviderDataSet:=ADOQuery1;
ADOQuery1.ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;'+ 'Data Source=f:\mcmygs.mdb;'+
'Persist Security Info=False;'+
'Jet OLEDB:Database Password=123456';
ADOQuery1.Close;
ADOQuery1.SQL.Text:='Select ⾃编号,合同号,币种,⾦额 from dzb'; ADOQuery1.Open;
MemTableEh1.Active:=True;
DBGridEh1.Flat:=True; //平⾯
DBGridEh1.TitleHeight:=20; //标题栏⾏⾼
DBGridEh1.OptionsEh:=DBGridEh1.OptionsEh+[dghShowRecNo]; //显⽰序号
DBGridEh1.ColumnDefValues.AlwaysShowEditButton:=True; //显⽰DropDowm图标
DBGridEh1.Columns[2].ImageList:=ImageList1;
DBGridEh1.Columns[2].ShowImageAndText:=True;
//PickList为显⽰出来的值,与ImageList中的图标顺序相对应
DBGridEh1.Columns[2].PickList.Add('美元');
DBGridEh1.Columns[2].PickList.Add('欧元');
DBGridEh1.Columns[2].PickList.Add('港币');
DBGridEh1.Columns[2].PickList.Add('⽇元');
DBGridEh1.Columns[2].PickList.Add('韩元');
//KeyList为数据库表中实际储存值,与PickList中值设置好相对应
DBGridEh1.Columns[2].KeyList.Add('USD');
DBGridEh1.Columns[2].KeyList.Add('EUR');
DBGridEh1.Columns[2].KeyList.Add('HKD');
DBGridEh1.Columns[2].KeyList.Add('JPY');
DBGridEh1.Columns[2].KeyList.Add('KRW');
DBGridEh1.Columns[2].Width:=80;
--------------------------------------------------------
作者:资料戊辰公子
链接:https://wenku.baidu.com/view/766a2f5c158884868762caaedd3383c4bb4cb4c9.html
来源:百度文库
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

标签:dbgrideh,picklist,Add,keylist,PickList,True,KeyList,Columns,DBGridEh1
来源: https://www.cnblogs.com/xionda/p/16441412.html