碰到个好怪的问题,晕死了。请大家给予帮助问题如下: 我做了个界面,用 stringgrid 做为输入界面,有个 隐藏的 edit .基本控件如下:
stringgrid
edit
bitbtn(原来储存的按钮) stringgrid : 13列,2行时,那个隐藏的 edit 显示出来后,可以输入中文
13列,3行时,那个隐藏的 edit 显示出来后,就没有办法输入中文了。可以输入 英文及数字 涉及到的代码如下:procedure TF_CaiGouDan.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin if stringgrid1.Cells[0,currentRow]='' then
exit;
if currentCol in [4,5,7,11,12] then
begin
randomEdit.Top :=stringgrid1.CellRect(currentCol,currentRow).Top +stringgrid1.Top+2 ;
randomEdit.Left :=stringgrid1.CellRect(currentCol,currentRow).Left +stringgrid1.Left+2 ;
randomEdit.Width :=stringgrid1.CellRect(currentCol,currentRow).Right -stringgrid1.CellRect(currentCol,currentRow).Left ; randomEdit.Text :=''; if currentCol=4 then
FourColLeft:=randomEdit.Left ; //记住 第四列 的左边位置,为了当 edit 到了一行的最后,再按 enter 键时
// 跳到 下一行 的第四列(如果有货号存在) if stringgrid1.Cells[currentCol,currentRow]<>'' then
randomEdit.Text :=stringgrid1.Cells[currentCol,currentRow]; randomEdit.Visible :=True;
randomEdit.SetFocus ;
exit;
end
else
randomEdit.Visible :=False;
end;procedure TF_CaiGouDan.StringGrid1SelectCell(Sender: TObject; ACol,
ARow: Integer; var CanSelect: Boolean);//取得当前行和列的值
begin
currentRow:=ARow;
currentCol:=ACol;
end;procedure TF_CaiGouDan.randomEditExit(Sender: TObject);//当 edit 退出时
begin
stringgrid1.Cells[currentCol,currentRow]:=randomEdit.Text ;
if currentCol in [4,5,7] then
fuzhi; // 是个计算的 procedure 。
end;
stringgrid
edit
bitbtn(原来储存的按钮) stringgrid : 13列,2行时,那个隐藏的 edit 显示出来后,可以输入中文
13列,3行时,那个隐藏的 edit 显示出来后,就没有办法输入中文了。可以输入 英文及数字 涉及到的代码如下:procedure TF_CaiGouDan.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin if stringgrid1.Cells[0,currentRow]='' then
exit;
if currentCol in [4,5,7,11,12] then
begin
randomEdit.Top :=stringgrid1.CellRect(currentCol,currentRow).Top +stringgrid1.Top+2 ;
randomEdit.Left :=stringgrid1.CellRect(currentCol,currentRow).Left +stringgrid1.Left+2 ;
randomEdit.Width :=stringgrid1.CellRect(currentCol,currentRow).Right -stringgrid1.CellRect(currentCol,currentRow).Left ; randomEdit.Text :=''; if currentCol=4 then
FourColLeft:=randomEdit.Left ; //记住 第四列 的左边位置,为了当 edit 到了一行的最后,再按 enter 键时
// 跳到 下一行 的第四列(如果有货号存在) if stringgrid1.Cells[currentCol,currentRow]<>'' then
randomEdit.Text :=stringgrid1.Cells[currentCol,currentRow]; randomEdit.Visible :=True;
randomEdit.SetFocus ;
exit;
end
else
randomEdit.Visible :=False;
end;procedure TF_CaiGouDan.StringGrid1SelectCell(Sender: TObject; ACol,
ARow: Integer; var CanSelect: Boolean);//取得当前行和列的值
begin
currentRow:=ARow;
currentCol:=ACol;
end;procedure TF_CaiGouDan.randomEditExit(Sender: TObject);//当 edit 退出时
begin
stringgrid1.Cells[currentCol,currentRow]:=randomEdit.Text ;
if currentCol in [4,5,7] then
fuzhi; // 是个计算的 procedure 。
end;
放在stringgrid上面,就当作一个输入项也好。