谁能帮我实现StringGrid的某列Cell具有下拉列表的功能。 谁能帮我实现StringGrid的某列Cell具有下拉列表的功能。 不要那种使用combobox嵌入的方法,有现成控件也可以。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我看只能使用combobox嵌入的方法了,除非使用第三方控件封装了的。 这是我以前写的procedure TFORM1.StringGridMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);var GridCoord: TGridCoord; Rect: TRect; I: Integer;begin ComboBoxParamstr.Visible := False; GridCoord := StringGrid.MouseCoord(X, Y); FRow := GridCoord.Y; FCol := GridCoord.X; if (FRow <= 0) or (FCol < 0) then exit; Rect := StringGrid.CellRect(FCol, FRow + 1); ComboBoxParamstr.Text := StringGrid.Cells[FCol,FRow]; ComboBoxParamstr.Top := Rect.Top - 2; ComboBoxParamstr.Left := Rect.Left + 10; ComboBoxParamstr.Width := Rect.Right - Rect.Left; ComboBoxParamstr.Visible := True; case GridCoord.X of 0://字段 begin ComboBoxParamstr.Items := FlstFields; end; 1://字段类型 begin ComboBoxParamstr.Visible := False; //ComboBoxParamstr.Items := FlstFieldTypes; end; 2://排序类型 begin ComboBoxParamstr.Items := FlstOrdType; end; 3://排序顺序 begin ComboBoxParamstr.Clear; for I := 1 to FMaxOrdNo do ComboBoxParamstr.Items.Add(IntToStr(I)); ComboBoxParamstr.Text := StringGrid.Cells[FCol,FRow]; end; 4://关系 begin ComboBoxParamstr.Items := FlstRelat; end; 5://准则 begin ComboBoxParamstr.Items := FlstRule; end; 6://值 begin ComboBoxParamstr.Items := FlstValue; end; end;end; 用Tstrings封装一个属性就可以,很简单 已经找到TMS.Component.Pack.Pro.v3.3中的TAdvStringGrid解决问题。还是非常感谢大家的回答。并向大家推荐这个控件,功能非常强,可以在StringGrid中整合combobox、checkbox、spinEdit等等。TMS的控件是获得大奖的,呵呵,我就不多说了,我还没用上手呢。 如何编写提取人对话的程序? 高分求解:QuickRep打印丢图问题,预览图像为黑色,急急急! 100分求通用查询模块源码~~~~ 如何检测输入框中填写想是否是自己想要的数据? 用MIDAS 开发分布式程序如何锁定数据?? dbgrid控件的简单问题 数据库备份与恢复! 请问怎么控制Treeview各项的上下间距?我没找到在哪里改啊! 关于dgRowselect的属性设置出错 绘制函数曲线的工具 一个棘手的问题。 怎样关闭这样的程序,两个独立的程序a,b,都是我用D写的,现需要在b中关闭a,语法请进来看可,谢谢???
procedure TFORM1.StringGridMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
GridCoord: TGridCoord;
Rect: TRect;
I: Integer;
begin
ComboBoxParamstr.Visible := False;
GridCoord := StringGrid.MouseCoord(X, Y);
FRow := GridCoord.Y;
FCol := GridCoord.X;
if (FRow <= 0) or (FCol < 0) then exit;
Rect := StringGrid.CellRect(FCol, FRow + 1);
ComboBoxParamstr.Text := StringGrid.Cells[FCol,FRow];
ComboBoxParamstr.Top := Rect.Top - 2;
ComboBoxParamstr.Left := Rect.Left + 10;
ComboBoxParamstr.Width := Rect.Right - Rect.Left;
ComboBoxParamstr.Visible := True;
case GridCoord.X of
0://字段
begin
ComboBoxParamstr.Items := FlstFields;
end;
1://字段类型
begin
ComboBoxParamstr.Visible := False;
//ComboBoxParamstr.Items := FlstFieldTypes;
end;
2://排序类型
begin
ComboBoxParamstr.Items := FlstOrdType;
end;
3://排序顺序
begin
ComboBoxParamstr.Clear;
for I := 1 to FMaxOrdNo do
ComboBoxParamstr.Items.Add(IntToStr(I));
ComboBoxParamstr.Text := StringGrid.Cells[FCol,FRow];
end;
4://关系
begin
ComboBoxParamstr.Items := FlstRelat;
end;
5://准则
begin
ComboBoxParamstr.Items := FlstRule;
end;
6://值
begin
ComboBoxParamstr.Items := FlstValue;
end;
end;
end;