我想实现在DBGrid中单击某个单元格时,然后把ComboBox定位到这个单元格的位置,请问如何实现
解决方案 »
- 如何得知 Chart 饼图的圆心?
- 菜鸟问题 循环 100分在线等
- 在IIS中的虚拟目录怎样用命令来创建虚拟目录的应用程序名称
- 请教如何将activexform得到的值传到网页上显示??
- 如何能让timage响应得到焦点和失去焦点的事件!
- 怎么在程序里面展开TreeView的子节点》!!!
- 三层架构中怎样处理数据同步?我每到一个公司面试都会问这个问题,怎么回答!?
- 唉!!怎么办.
- 一个让人迷惑的问题
- ----散分--- 一个月不到,专家分从0到5XX,共参与了 150 个问题,有 50 个问题得分,还有若干问题未结。
- 大家都来谈自己的感受或想法,升星,散分!
- 一个很值得研究的问题,感兴趣的进来看看
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
在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;//////////////////////////////////////////////////
这样就可以了