首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

stringgrid有关问题

2012-03-11 
stringgrid问题我在stringgrid中有一列我用了一个日期控件套在里面了,我实现了回车跳下一格的功能,但是一

stringgrid问题
我在stringgrid中有一列我用了一个日期控件套在里面了,我实现了回车跳下一格的功能,但是一到这个日期控件的列就跳不过去

求指点一下
procedure TFrmadvinsert.StringGrid2KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
var i:integer;
R : TRect;
Org : TPoint;
begin
with StringGrid2 do
begin
  if Key = VK_RETURN then
  begin
  if Col<ColCount-1 then
  begin
  Col:=Col+1;
  end
  else
  begin
  Col:=1;
  if Row<RowCount-1 then
  Row:=Row+1
  else
  begin
  StringGrid2 .RowCount :=StringGrid2 .RowCount+1;
  with StringGrid2 do
  begin
  for i:=1 to RowCount do
  Cells [1,i]:=FormatFloat ('00',i);
  end;
  row:=RowCount-1;
  Col:=1;
  end;
  end;
  end;
end;
end;//这是回车跳下一格



procedure TFrmadvinsert.StringGrid2SelectCell(Sender: TObject; ACol,
  ARow: Integer; var CanSelect: Boolean);
var
R : TRect;
Org : TPoint;
begin

 with TStringGrid(Sender) do
 begin
 if ACol =2 then
  begin
  Perform(WM_CANCELMODE, 0, 0);
  R := CellRect(Acol,ARow);
  Org := Self.ScreenToClient(ClientToScreen(R.TopLeft));
  With regulationdate do
  begin
  Setbounds(org.X, org.Y, R.Right-R.Left, Height);
  value:=date;
  Show;
  BringTofront;
  SetFocus;
  end;
  end;
 end;
end;//这是点击到格子里面的代码

[解决办法]
日期控件里面有好几个焦点,年,月,日,不信你试试

热点排行