我想实现在DBGrid中单击某个单元格时,然后把ComboBox定位到这个单元格的位置,请问如何实现
解决方案 »
- 关于ToolButton的小问题
- DirectShow写的媒体播放器,用于显示画面的控件在播放时被画面复盖的地方不响应鼠标事件,这是怎么回事啊?如 click、dbclick等都不响应
- **********我是做开发的,现在主攻3DMAX,做三维动画,大家说有前途吗,招这方面的都是什么公司,工资高吗,谢谢了
- 不同类型的数值什么运
- JAVA程序员请教一个delphi面向对象开发问题
- 怎么处理WM_HOTKEY消息?
- Delphi中实现foxpro数据库中的&替换功能?
- 学Delphi买什么书好?
- LIKE为什么不能实现模糊查询?
- 请问如何才能捕获 PostQuitMessage(0)的消息??
- 大家都来谈自己的感受或想法,升星,散分!
- 一个很值得研究的问题,感兴趣的进来看看
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
在dbgrid的onDrawColumnCell事件里面处理 如下:
我处理的是显示金额的一个控件,你修改一下吧
procedure Tfrm_newpj.DBGDrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
var
OldColor, OldFontColor: TColor;
begin
if CheckCurrencyField(Column.FieldName) then
begin
if (gdFocused in State) then
begin
sncDBCurrencyEdit.Left := Rect.Left + DBG.Left+2;
sncDBCurrencyEdit.Top := Rect.Top + DBG.top+2;
sncDBCurrencyEdit.Width := Rect.Right-Rect.Left;
sncDBCurrencyEdit.Height := Rect.Bottom- Rect.Top;
SetHighLightColor;
if (sncDBCurrencyEdit.Tag=1) and not sncDBCurrencyEdit.Visible then
sncDBCurrencyEdit.Visible := True;
end
else
begin
OldColor := sncDBCurrencyEdit.Color;
OldFontColor := sncDBCurrencyEdit.Font.Color;
SetNormalColor;
DrawCurrencyFrame(DBG.Canvas, Rect, sncDBCurrencyEdit, Column.Field.AsFloat);
sncDBCurrencyEdit.Color := OldColor;
sncDBCurrencyEdit.Font.Color := OldFontColor;
end;
end;
end;
Field: TField; State: TGridDrawState);
begin
if (gdFocused in State) then
begin
ComboBox1.Left:=Rect.Left+DBGrid1.Left;
ComboBox1.Top:=Rect.Top+DBGrid1.Top;
ComboBox1.Width:=Rect.Right-Rect.Left;
ComboBox1.Height:=Rect.Bottom-Rect.Top;
ComboBox1.Visible:=true;
end;
end;//////////////////////////////////////////////////
这样就可以了