L
lynch2611
Unregistered / Unconfirmed
GUEST, unregistred user!
StringGrid中嵌入其他控件问题!比如Combox,我是这样写的,但当我改变列宽的时候,
Combox的大小不变化了(列宽变大时正常,列宽变小时就不变化了)
procedure TWatchListForm.StringGrid1DrawCell(Sender: TObject; ACol,
ARow: Integer; Rect: TRect; State: TGridDrawState);
var
CBLeft, CBTop, CBWidth: Integer;
begin
{if (gdFocused in state) or (gdSelected in state) then
begin
CBLeft := StringGrid1.CellRect(ACol, ARow).Left;
CBTop := StringGrid1.CellRect(ACol, ARow).Top;
CBWidth := StringGrid1.CellRect(ACol, ARow).Right - StringGrid1.CellRect(ACol, ARow).Left;
ComboBox1.Left := CBLeft + 1;
ComboBox1.Top := CBTop + 1;
ComboBox1.Width := CBWidth;
ComboBox1.Visible := True;
ComboBox1.SetFocus;
end;
end;
对了,这种问题有通过API解决的方法吗?
Combox的大小不变化了(列宽变大时正常,列宽变小时就不变化了)
procedure TWatchListForm.StringGrid1DrawCell(Sender: TObject; ACol,
ARow: Integer; Rect: TRect; State: TGridDrawState);
var
CBLeft, CBTop, CBWidth: Integer;
begin
{if (gdFocused in state) or (gdSelected in state) then
begin
CBLeft := StringGrid1.CellRect(ACol, ARow).Left;
CBTop := StringGrid1.CellRect(ACol, ARow).Top;
CBWidth := StringGrid1.CellRect(ACol, ARow).Right - StringGrid1.CellRect(ACol, ARow).Left;
ComboBox1.Left := CBLeft + 1;
ComboBox1.Top := CBTop + 1;
ComboBox1.Width := CBWidth;
ComboBox1.Visible := True;
ComboBox1.SetFocus;
end;
end;
对了,这种问题有通过API解决的方法吗?