关于 TStringGrid 的问题(50分)

Z

_zeus

Unregistered / Unconfirmed
GUEST, unregistred user!
如何将 TStringGrid 的某一个单元格做成带下拉列表的?
 
当焦点到该单元时,触发一个下拉列表,所取得值在写入单元格内。试一试
 
还有别的方法吗?
这好像不太灵活,除非下拉列表是动态生成的,但这又感觉不台好...
我说的别的方法是不使用别的控件就能做到的方法。
 
我就是这样做的
反应很快 很好用

//该过程,在StringGrid上动态创建ComboBOx,并初始化
procedure TDlgProjInput2.CreateComboBox(Rownum,Colnum,initIndex:integer;
initValue:string);
var
itemList:TstringList;
i:integer;
begin
itemList:=TstringList.Create;
with StringGrid1 do
begin
Objects[Colnum,Rownum]:=TComboBox.Create(Self);
with Objects[Colnum,Rownum] as TComboBox do
begin
Parent := Self;
Windows.SetParent((Objects[Colnum,Rownum] as TComboBox).Handle, stringGrid1.Handle);
//width:=65;
//Height:=24;
Font.Size:=11;
Font.Color:=clBlue;
visible:=False;
style:=csDropDownList;
itemList.CommaText:=initValue;

for i:=0 to itemList.Count-1 do
begin
Items.Add(itemList);
end;
ItemIndex:=initIndex;
Cells[Colnum,Rownum]:=Trim(text);
Onchange:=ComboBoxChange;
end;
end;
itemList.Free;
end;


 
用advstringgrid吧
功能强点,下拉只要改下AEditor就行了
 
To 土土: I'm sorry that I didn't give you anything because I'd
received your reply just after I'd gave Cardinal and thaver them.
But what's AdvStringGrid, can you tell me?
 
顶部