本站首页    管理页面    写新日志    退出


«September 2025»
123456
78910111213
14151617181920
21222324252627
282930


公告
================

注会练习软件
http://www.cpasoft.com.cn
我的注会软件官网

http://blog.163.com/abc7105@126/

 

 


哈哈,热爱快“过气”的DELPHI


我的分类(专题)

日志更新

最新评论

留言板

链接

Blog信息
blog名称:注册会计师(注会)练习软件
日志总数:398
评论数量:116
留言数量:27
访问次数:3273292
建立时间:2005年6月6日




advstringgrid控件中使用弹出式tcolumncomboeditlink控件
软件技术

吕向阳 发表于 2009/1/4 11:18:52

1.加入一个tms的tcolumncomboeditlink 2.可设为多列,它实际是一个lookupedit式的控件 3.在下列事件中加入相应代码 procedure TForm1.mxgridGetEditorProp(Sender: TObject; ACol, ARow: Integer;  AEditLink: TEditLink);begin   if ACol in [2] then    with (AEditLink as TColumnComboEditLink).Combo do    begin      BeginUpdate;      Columns.Items[0].Width := 64;      Columns.Items[1].Width := DropWidth - 64;      Columns.Items[1].Font.Style := [fsItalic];      EndUpdate;    end;end; 4.同样处理下列事件 procedure TForm1.mxgridGetEditorType(Sender: TObject; ACol, ARow: Integer;  var AEditor: TEditorType);begin  with mxgrid do  begin     if ACol = 2 then    begin      AEditor := edCustom;      mxgrid.EditLink := cmb1;    end;     if MXGRID.Cells[ACOL, AROW] <> '' then    begin      MouseActions.DirectComboDrop := FALSE;      MouseActions.DirectEdit := True;    end    else    begin      MouseActions.DirectComboDrop := TRUE;      MouseActions.DirectEdit := TRUE;    end;  end;end; 5.还有一个事件要处理 procedure TForm1.mxgridHasComboBox(Sender: TObject; ACol, ARow: Integer;  var HasComboBox: Boolean);begin  HasComboBox := ((ACol = 2) and (mxgrid.Cells[2, ARow] <> ''));end; 6.最后要让它自己弹出,要加入cmb1.Combo.DroppedDown := true;这个关键语句 procedure TForm1.mxgridGetEditText(Sender: TObject; ACol, ARow: Integer;  var Value: string);begin  if ACol in [2] then    cmb1.Combo.DroppedDown := true;end; 我觉得研究advstringgrid后,它最适合一对多的明细数据的输入处理, delphi自带的stringgrid有很多待完善的地方: 1.没有oncellchange事件不便于响应当某单元格变化后,其他值相应变化的问题 2.没有底部的求和功能 3.加挂弹出式编辑元件,复选框元件困难,这太常用到了 4.无方便的图片处理功能 advstringgrid是对它的一个完善, 另外:加入一个按左方向键跳转到上一单元格 procedure TForm1.mxgridKeyDown(Sender: TObject; var Key: Word;  Shift: TShiftState);begin  if key=vk_left then    if mxgrid.Col > 1 then      mxgrid.Col := mxgrid.Col - 1;end; == 得到列表的值 var i:integer; strs:TStrings; str:string; begin adoquery1.Close; adoquery1.SQL.Clear; adoquery1.SQL.Add('select * from 表 order by id'); adoquery1.Open; adoquery1.First; strs:= TStringList.Create; for i:=0 to adoquery1.RecordCount -1 do   begin     cb1.ComboItems.Add;     str:=adoquery1.FieldByName('id').AsString+','+           adoquery1.FieldByName('name').AsString+','+           formatdatetime('hh:mm:ss',adoquery1.FieldByName('starttime').AsDateTime)+','+           formatdatetime('hh:mm:ss',adoquery1.FieldByName('endtime').AsDateTime);     strs.CommaText:=str;     cb1.ComboItems.Items[i].Strings.AddStrings(strs);     adoquery1.Next;   end; end; 


阅读全文(2599) | 回复(0) | 编辑 | 精华
 



发表评论:
昵称:
密码:
主页:
标题:
验证码:  (不区分大小写,请仔细填写,输错需重写评论内容!)



站点首页 | 联系我们 | 博客注册 | 博客登陆

Sponsored By W3CHINA
W3CHINA Blog 0.8 Processed in 0.047 second(s), page refreshed 144797450 times.
《全国人大常委会关于维护互联网安全的决定》  《计算机信息网络国际联网安全保护管理办法》
苏ICP备05006046号