这样生成的组件为什么看不到

jungle_1978 2010-04-14 08:40:37
object Form1: TForm1
Left = 192
Top = 114
Width = 696
Height = 480
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Panel1: TPanel
Left = 0
Top = 0
Width = 185
Height = 446
Align = alLeft
Caption = 'Panel1'
TabOrder = 0
object ComboBox62: TComboBox
Left = 56
Top = 360
Width = 145
Height = 21
ItemHeight = 13
TabOrder = 0
Text = 'ComboBox62'
OnChange = ComboBox62Change
end
end
object Panel2: TPanel
Left = 185
Top = 0
Width = 503
Height = 446
Align = alClient
Caption = 'Panel2'
TabOrder = 1
object mygroupbox: TGroupBox
Left = 1
Top = 1
Width = 501
Height = 368
Align = alTop
Caption = 'mygroupbox'
TabOrder = 0
end
object Button1: TButton
Left = 200
Top = 384
Width = 75
Height = 25
Caption = 'Button1'
TabOrder = 1
OnClick = Button1Click
end
end
end

--------------------------------------------------------------------------------
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;

type
TForm1 = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
mygroupbox: TGroupBox;
Button1: TButton;
ComboBox62: TComboBox;
procedure Button1Click(Sender: TObject);
procedure ComboBox62Change(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
v_height:integer;
nc_label:tlabel;
nc_combobox1:tcombobox;
begin
nc_label:=tlabel.Create(self);
nc_label.Parent:=mygroupbox;
nc_label.Caption:='v_cap';
nc_label.top:=mygroupbox.Top+1*v_height+24;
nc_label.left:=mygroupbox.left+24;
nc_label.width:=150;
nc_label.Height:=13;
nc_label.Visible:=true;

nc_combobox1:=tcombobox.Create(self);
nc_combobox1.Parent:=mygroupbox;
nc_combobox1.Top:=mygroupbox.Top+1*v_height+16;
nc_combobox1.left:=mygroupbox.left+216;
nc_combobox1.width:=49;
nc_combobox1.Height:=21;
nc_combobox1.Items.Append('0');
nc_combobox1.Items.Append('1');
nc_combobox1.Items.Append('2');
nc_combobox1.Items.Append('3');
nc_combobox1.Items.Append('4');
nc_combobox1.Items.Append('5');
nc_combobox1.OnChange:=ComboBox62Change;
nc_combobox1.Visible:=true;

end;

procedure TForm1.ComboBox62Change(Sender: TObject);
begin
//
end;

end.
...全文
111 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
火龙岛主 2010-04-15
  • 打赏
  • 举报
回复
看看v_height的值,是不是太大了,被覆盖了!
ljluck7687 2010-04-14
  • 打赏
  • 举报
回复
nc_label.top:=1*v_height+24;
  • 打赏
  • 举报
回复
帮你顶吧
hongqi162 2010-04-14
  • 打赏
  • 举报
回复
显示的位置问题
柯本 2010-04-14
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 jiap1723 的回复:]
感觉是你坐标定义的问题v_height没有初始化值,那么在delphi下 就是随机16位整数 很有可能超过你的屏幕
[/Quote]
应该就是v_height的问题,改v_height=1,就可以了
CACACACACA 2010-04-14
  • 打赏
  • 举报
回复
nc_label:=tlabel.Create(self);
nc_label.Parent:=mygroupbox; ????
nc_label.Caption:='v_cap';
nc_label.top:=mygroupbox.Top+1*v_height+24; ???
nc_label.left:=mygroupbox.left+24;

既然父是mygroupbox,为什么label的top/left是父top/left呢?
风之谷 2010-04-14
  • 打赏
  • 举报
回复
感觉是你坐标定义的问题v_height没有初始化值,那么在delphi下 就是随机16位整数 很有可能超过你的屏幕
jungle_1978 2010-04-14
  • 打赏
  • 举报
回复
delphi7+winxpsp2环境

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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