------------------------------------------------------------------------- StringGrid //-------- procedure TForm1.StringGrid1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); var i, j: Integer; begin for i := 0 to StringGrid1.ColCount -1 do for j := 0 to StringGrid1.RowCount -1 do if (StringGrid1.CellRect(i,j).Left < x ) and (StringGrid1.CellRect(i,j).Right > x ) and (StringGrid1.CellRect(i,j).Top < y) and (StringGrid1.CellRect(i,j).Bottom > y ) and (StringGrid1.Font.PixelsPerInch * Length(StringGrid1.Cells[i,j]) > StringGrid1.ColWidths[i])then StringGrid1.Hint := StringGrid1.Cells[i,j] end;-------------------------------------------------------------------------- Edit //---- procedure TForm1.Edit1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); begin if(Edit1.Font.PixelsPerInch * Length(Edit1.Text) > Edit1.Width)then Edit1.Hint := Edit1.Text; end;
修改 procedure TForm1.Edit1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); begin Edit1.Hint := ''; if(Edit1.Font.PixelsPerInch * Length(Edit1.Text) div 15 > Edit1.Width)then begin Edit1.Hint := Edit1.Text; end; end;procedure TForm1.StringGrid1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); var i, j: Integer; begin StringGrid1.Hint := ''; for i := 0 to StringGrid1.ColCount -1 do for j := 0 to StringGrid1.RowCount -1 do if (StringGrid1.CellRect(i,j).Left < x ) and (StringGrid1.CellRect(i,j).Right > x ) and (StringGrid1.CellRect(i,j).Top < y) and (StringGrid1.CellRect(i,j).Bottom > y ) and (StringGrid1.Font.PixelsPerInch * Length(StringGrid1.Cells[i,j]) div 15 > StringGrid1.ColWidths[i])then StringGrid1.Hint := StringGrid1.Cells[i,j] end;
Y: Integer);
begin
Edit1.Hint := Edit1.Text;
end;
Edit1的showHint 设为true
还有GRID表中的显示怎么实现?
大家帮忙啊
StringGrid
//--------
procedure TForm1.StringGrid1MouseMove(Sender: TObject; Shift: TShiftState;
X, Y: Integer);
var
i, j: Integer;
begin
for i := 0 to StringGrid1.ColCount -1 do
for j := 0 to StringGrid1.RowCount -1 do
if (StringGrid1.CellRect(i,j).Left < x ) and (StringGrid1.CellRect(i,j).Right > x )
and (StringGrid1.CellRect(i,j).Top < y) and (StringGrid1.CellRect(i,j).Bottom
> y )
and (StringGrid1.Font.PixelsPerInch * Length(StringGrid1.Cells[i,j]) > StringGrid1.ColWidths[i])then
StringGrid1.Hint := StringGrid1.Cells[i,j]
end;--------------------------------------------------------------------------
Edit
//----
procedure TForm1.Edit1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if(Edit1.Font.PixelsPerInch * Length(Edit1.Text) > Edit1.Width)then
Edit1.Hint := Edit1.Text;
end;
//----
procedure TForm1.Edit1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if(Edit1.Font.PixelsPerInch * Length(Edit1.Text) > Edit1.Width)then
Edit1.Hint := Edit1.Text;
end;
procedure TForm1.Edit1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
Edit1.Hint := '';
if(Edit1.Font.PixelsPerInch * Length(Edit1.Text) div 15 > Edit1.Width)then
begin
Edit1.Hint := Edit1.Text;
end;
end;procedure TForm1.StringGrid1MouseMove(Sender: TObject; Shift: TShiftState;
X, Y: Integer);
var
i, j: Integer;
begin
StringGrid1.Hint := '';
for i := 0 to StringGrid1.ColCount -1 do
for j := 0 to StringGrid1.RowCount -1 do
if (StringGrid1.CellRect(i,j).Left < x ) and (StringGrid1.CellRect(i,j).Right > x )
and (StringGrid1.CellRect(i,j).Top < y) and (StringGrid1.CellRect(i,j).Bottom > y )
and (StringGrid1.Font.PixelsPerInch * Length(StringGrid1.Cells[i,j]) div 15 > StringGrid1.ColWidths[i])then
StringGrid1.Hint := StringGrid1.Cells[i,j]
end;