请教各位大虾,,,好何把combox添加到stringgrid里呢。
解决方案 »
- 大家好,求助一个比较复杂的有关程序控制图片组合的问题
- 可以不用Read/WriteProcessMemory读写内存吗?
- 高手入:关于assign null的问题
- 请教高手关于多层结构的问题
- 我用INDY做FTP下载,我怎么知道下载完成了?
- 關於 crystal report 9的不能根據表裏的數據自動刷新,着急!!高手幫忙
- 高分求源码。怎么在Delphi中建立套帐。
- 关于在DataBase中Image字段的问题
- 春节快乐!本人一无才、二无财、只好用http://www.japanpig.com/bu.htm这材,向大家问好了!
- 大哥们我有问题~~~请教
- 从大到小并且从多到少的排序
- DELPHI中有没有像C++链表一样的数据结构,可以方便实现删除
procedure TForm1.StringGrid1SelectCell(Sender: TObject; ACol,
ARow: Integer; var CanSelect: Boolean);
var
i,m,n,j:Integer;
begin
i:=self.StringGrid1.TopRow-1;
n:=0;
if ARow=0 then
n:=0
else
begin
for j:=i to arow-1 do
n:=n+self.StringGrid1.RowHeights[j];
end;
self.ComboBox1.Top:=self.StringGrid1.Top+n+(arow-i+1)*self.StringGrid1.GridLineWidth;
m:=0;
if ACol=0 then
m:=0
else
begin
for i:=0 to acol-1 do
m:=m+self.StringGrid1.ColWidths[i];
end;
self.ComboBox1.Left:=self.StringGrid1.Left+m+(acol+1)*self.StringGrid1.GridLineWidth;
self.ComboBox1.Visible:=true;
self.ComboBox1.Width:=self.StringGrid1.ColWidths[ACol];
self.ComboBox1.Height:=self.StringGrid1.RowHeights[ARow];
end;
方法是放一个combobox
再放一个 stringgrid 并设置选择一行,不是单个的距形
在stringgrid 里的选择行事件里
得到位置,再按位置放上combobox
var
vRect: TRect;
begin
if (StrGrid.Row>0) and (StrGrid.Row<StrGrid.RowCount) then
begin
if (StrGrid.Col=2) then
begin
vRect := StrGrid.CellRect(StrGrid.Col,StrGrid.Row);
ComboBox1.Top := StrGrid.Top + vRect.Top+1;
ComboBox1.Width := vRect.Right-vRect.Left;
ComboBox1.Height := vRect.Bottom - vRect.Top ;
ComboBox1.Left := StrGrid.left + vRect.Left + 1;
ComboBox1.Text := strGrid.Cells[StrGrid.Col,StrGrid.Row];
ComboBox1.Visible := true;
ComboBox1.SetFocus;
end;
if (StrGrid.Col=1) then
begin
vRect := StrGrid.CellRect(StrGrid.Col,StrGrid.Row);
ComboBox1.Top := StrGrid.Top + vRect.Top+1;
ComboBox1.Width := vRect.Right-vRect.Left;
ComboBox1.Height := vRect.Bottom - vRect.Top ;
ComboBox1.Left := StrGrid.left + vRect.Left + 1;
ComboBox1.Text := strGrid.Cells[StrGrid.Col,StrGrid.Row];
ComboBox1.Visible := true;
ComboBox1.SetFocus;
end;
end else
ComboBox1.Visible := false;
end;