放上一个ComboBox,然后将其Visible属性社为false;procedure TForm1.StringGrid1SelectCell(Sender: TObject; ACol, ARow: Integer; var CanSelect: Boolean); var i,w,h:integer; begin w:=0; h:=0; for i:= 0 to acol-1 do w:=w+stringgrid1.ColWidths[i]; for i:=0 to arow-1 do h:=h+stringgrid1.RowHeights[i]; w:=w+stringgrid1.Left; h:=h+stringgrid1.Top; comboBox1.Left :=w+6; combobox1.Top :=h+2; combobox1.Width := stringgrid1.ColWidths[acol]; combobox1.Height :=stringgrid1.RowHeights[arow]; comboBox1.Text :=''; combobox1.Visible :=true; nowRow:=aRow; nowcol:=aCol; cbAppear:=true; end;procedure TForm1.FormCreate(Sender: TObject); begin comboBox1.Items.Add('美国'); comboBox1.Items.Add('中国'); comboBox1.items.Add('英国'); end;procedure TForm1.ComboBox1Change(Sender: TObject); begin if cbAppear then begin stringgrid1.Cells[nowCol,nowRow]:=combobox1.Text ; combobox1.Visible :=false; cbAppear:=false; end; end;end.
ARow: Integer; var CanSelect: Boolean);
var
i,w,h:integer;
begin
w:=0;
h:=0;
for i:= 0 to acol-1 do
w:=w+stringgrid1.ColWidths[i]; for i:=0 to arow-1 do
h:=h+stringgrid1.RowHeights[i]; w:=w+stringgrid1.Left;
h:=h+stringgrid1.Top;
comboBox1.Left :=w+6;
combobox1.Top :=h+2;
combobox1.Width := stringgrid1.ColWidths[acol];
combobox1.Height :=stringgrid1.RowHeights[arow];
comboBox1.Text :='';
combobox1.Visible :=true;
nowRow:=aRow;
nowcol:=aCol;
cbAppear:=true;
end;procedure TForm1.FormCreate(Sender: TObject);
begin
comboBox1.Items.Add('美国');
comboBox1.Items.Add('中国');
comboBox1.items.Add('英国');
end;procedure TForm1.ComboBox1Change(Sender: TObject);
begin
if cbAppear then
begin
stringgrid1.Cells[nowCol,nowRow]:=combobox1.Text ;
combobox1.Visible :=false;
cbAppear:=false;
end;
end;end.
双击该表格,添加相应的字段.再选定想要的字段..然后在它的PickList输入就行..
1 伪造法,如insert2003(高级打字员)所说
2 第三方,上面的很多大虾都说过了
提供一个网址,http://www.2ccc.com 大富翁的用户就可以用
3 自己定义一个组件
有耐性
下面是对insert2003(高级打字员)的程序的一点改进
把:
comboBox1.Left :=w+6;
combobox1.Top :=h+2;
两行改为:
comboBox1.Left :=w+2+StringGrid1.GridLineWidth*ACol;
combobox1.Top :=h+2+StringGrid1.GridLineWidth*ARow;
因为还要算上网格线条的高度才能正好吻合