有关在stringgrid中添加滚动条疑问 |
尚未結案
|
like
一般會員 發表:30 回覆:35 積分:18 註冊:2005-03-10 發送簡訊給我 |
|
syntax
尊榮會員 發表:26 回覆:1139 積分:1258 註冊:2002-04-23 發送簡訊給我 |
試過嗎?
StringGrid B.Parent = StringGrid A 手邊沒工具可以幫你測,但聽起來可能是這樣 :B 不在 A 的子項內 ===================引 用 like 文 章=================== 在上图那种状态中,在StringGrid【A】中,单击了最后一行第一个单元格后,弹出了【B】,但是【B】不能将所有的内容显示出来,而【A】中也没 有滚动条出现,请问,如何可以将【A】的滚动条调出? 我在程序创建[B]时,加了showscrollbar()也不能将【A】中的垂直滚动条显 示出来。 而程序经过几次测试,有一次出现了滚动条,但是滚动块不能动,只是停留在上方! 请问该问题”如何在【A】中添加滚动条,使其向下滚动可以显示出【B】的全部内容?“有何办法解决?还请大大们指点, 谢谢! |
like
一般會員 發表:30 回覆:35 積分:18 註冊:2005-03-10 發送簡訊給我 |
我的代码如下:
将vp.parent:=self;后可以完全显示出vg的表格(也就是图中的B表),但是调出了vp后,单击vg中的单元格,则会报错“Control '' have not parent window", 我跟踪调试了一下,发现是在OrderContent的onSetEditText事件中报错的。出错后,我点击出错提示上的确定,程序还可以继续运行,并且不会再报错了。 这个错误是如何造成的呢?如果vp.parent指向Ordercontent则不会报此类错。 还请syntax大大指点,谢谢!!! 代码如下: [code delphi] unit order; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Grids, StrUtils, ExtCtrls, StdCtrls, Buttons; type TForder = class(TForm) Panel1: TPanel; OrderContent: TStringGrid; procedure OrderContentDblClick(Sender: TObject); procedure FormCreate(Sender: TObject); procedure OrderContentDrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); procedure OrderContentSetEditText(Sender: TObject; ACol, ARow: Integer; const Value: String); private { Private declarations } vP:TPanel; vG:TStringGrid; noid:string; procedure crCowList(tj:string); procedure crCowDBClick(Sender:TObject); procedure getCowValue; public { Public declarations } end; var Form1:TForder ; implementation {$R *.dfm} { TForm1 } procedure TFOrder.crCowList(tj:string); const cowTitle:array [0..4] of string=('aa','bb','cc','dd','ee'); var i,j,n:integer; ntop,nleft,nw:integer; nRect:TRect; smin,smax:integer; begin i:=0;j:=1;n:=0; if Assigned(vP) then begin FreeAndNil(vp); end; nRect:=OrderContent.CellRect(OrderContent.col,OrderContent.Row); ntop:=OrderContent.Top nRect.Bottom 3; nleft:=OrderContent.Left nRect.Left 3; vP:=TPanel.Create(nil); vP.Height:=200; vP.Caption:=''; vP.Parent:=Self; //vp.Parent:=OrderContent; vP.Visible:=False; vP.Left:=nleft; vP.Top:=ntop; vG:=TStringGrid.Create(vp); vG.Parent:=vP; vG.Align:=alClient; vG.Options:=vG.Options [goRowSelect]; vG.FixedCols:=0; vG.Font.Size:=9; vG.ColCount:=5; for i:=0 to 4 do vG.Cells[i,0]:=cowTitle[i]; vG.rowCount:=5; for j:=0 to 4 do for i:=0 to 4 do vg.cells[i,j]:='abcd'; nw:=0; for i:=0 to 4 do nw:=nw vG.ColWidths[i]; vp.Width:=nw 20; vP.Visible:=True; end; procedure TFOrder.OrderContentDblClick(Sender: TObject); begin if (OrderContent.Col=0) then crCowList(trim(OrderContent.Cells[0,OrderContent.row])) else if OrderContent.Col<>0 then if Assigned(vp) then FreeAndNil(vp); end; procedure TFOrder.crCowDBClick(Sender: TObject); begin if (vG.Row>0) and (trim(vG.Cells[0,vG.Row])<>'') then begin getCowValue; end; vp.Hide; end; procedure TFOrder.FormCreate(Sender: TObject); const cowFT:array [0..7] of string=('aa','规bb','cc','dd','ee','ff','gg','hh'); cowFW:array [0..7] of Integer=(100,100,50,50,50,120,120,200); var i:integer; begin OrderContent.ColCount:=High(cowFt) 1; for i:=Low(cowFT) to High(cowFT) do begin OrderContent.Cells[i,0]:=cowFT[i]; OrderContent.ColWidths[i]:=cowFW[i]; end; end; procedure TFOrder.OrderContentSetEditText(Sender: TObject; ACol, ARow: Integer; const Value: String); begin if (Assigned(vp) and vP.Visible) then crCowList(value); end; procedure TFOrder.getCowValue; begin OrderContent.Cells[0,OrderContent.Row]:=vG.Cells[1,vG.row]; OrderContent.Cells[1,OrderContent.Row]:=vG.Cells[2,vG.row]; OrderContent.Cells[2,OrderContent.Row]:=vG.Cells[3,vG.row]; OrderContent.Cells[3,OrderContent.Row]:=vG.Cells[4,vG.row]; end; end. ========================================= object FOrder: TFOrder Left = 246 Top = 66 Width = 716 Height = 563 Caption = #35746#21333 Color = clBtnFace Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -11 Font.Name = 'MS Sans Serif' Font.Style = [] OldCreateOrder = False OnCreate = FormCreate PixelsPerInch = 96 TextHeight = 13 object Panel1: TPanel Left = 0 Top = 0 Width = 708 Height = 529 Align = alClient Caption = 'Panel1' TabOrder = 0 object OrderContent: TStringGrid Left = 1 Top = 1 Width = 706 Height = 374 Align = alTop FixedCols = 0 RowCount = 14 Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -12 Font.Name = 'MS Sans Serif' Font.Style = [] Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goColSizing, goEditing] ParentFont = False TabOrder = 0 OnDblClick = OrderContentDblClick OnSetEditText = OrderContentSetEditText end end end [/code] ===================引 用 syntax 文 章=================== 試過嗎? StringGrid B.Parent = StringGrid A 手邊沒工具可以幫你測,但聽起來可能是這樣 :B 不在 A 的子項內
編輯記錄
like 重新編輯於 2010-03-13 13:34:52, 註解 無‧
|
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |