本文主要是介绍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中的keylist,picklist的用法的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!