求解stringgrid

randee_luo 2009-12-18 09:59:01
请教各位大虾,,,好何把combox添加到stringgrid里呢。
...全文
148 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
阿三 2009-12-22
  • 打赏
  • 举报
回复
procedure TForm1.StrGridClick(Sender: TObject);
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;
qkhhxkj102 2009-12-21
  • 打赏
  • 举报
回复
以前做过
方法是放一个combobox
再放一个 stringgrid 并设置选择一行,不是单个的距形
在stringgrid 里的选择行事件里
得到位置,再按位置放上combobox
yongyuanwang 2009-12-21
  • 打赏
  • 举报
回复
控制ComboBox1在StringGrid上显示的位置,来达到你说的那种效果
无条件为你 2009-12-21
  • 打赏
  • 举报
回复
关注!
yct0605 2009-12-21
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 jxlhc09 的回复:]
引用 6 楼 liuahuilele 的回复:
”啊哦“  好亲切啊  是我网名
帮顶了

  呵呵。。。
有没有学习的群呢。。。
[/Quote]
你搜索一下,应该有很多D群的。
randee_luo 2009-12-20
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 liuahuilele 的回复:]
”啊哦“  好亲切啊  是我网名
帮顶了
[/Quote]
呵呵。。。
有没有学习的群呢。。。
liuahuilele 2009-12-19
  • 打赏
  • 举报
回复
”啊哦“ 好亲切啊 是我网名
帮顶了
randee_luo 2009-12-19
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 lovelymelon 的回复:]
我测试了啊,哪不行?
[/Quote]

啊哦。。。那我要是只想在一列上加它呢。。。
lovelymelon 2009-12-19
  • 打赏
  • 举报
回复
我测试了啊,哪不行?
randee_luo 2009-12-19
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 lovelymelon 的回复:]
Delphi(Pascal) codeprocedure 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=0the?-
[/Quote]


这个怎么不行呢??
lovelymelon 2009-12-19
  • 打赏
  • 举报
回复

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;

dinoalex 2009-12-18
  • 打赏
  • 举报
回复
http://www.2ccc.com/article.asp?articleid=3066

2,497

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 数据库相关
社区管理员
  • 数据库相关社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧