![]() |
|
|
Регистрация | << Правила форума >> | FAQ | Пользователи | Календарь | Поиск | Сообщения за сегодня | Все разделы прочитаны |
![]() |
|
Опции темы | Поиск в этой теме | Опции просмотра |
#1
|
|||
|
|||
![]() Добрый день. Можно ли в Дельфи сделать так, чтобы компонент (допустим Label, Button) принадлежал не форме, а GroupBox. То есть, чтобы программно вызывался Form1.GroupBox1.Label1, а не Form1.Label1. Если можно, то как?
|
#2
|
||||
|
||||
![]() Зачем такое? Как вариант:
Код:
Label1.Parent := GroupBox1; |
#3
|
|||
|
|||
![]() А из редактора объектов родителя можно установить?
|
#4
|
||||
|
||||
![]() Параметра Parent там нет, есть немного иные настройки, но они не относятся к Вашему вопросу.
|
#5
|
||||
|
||||
![]() Цитата:
Пишу программы за еду. __________________ |
#6
|
||||
|
||||
![]() Form1.GroupBox1.Label1.Caption:='Hobbit';
Код:
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TGroupBox = class(StdCtrls.TGroupBox) public Label1: TLabel; constructor Create(AOwner: TComponent); override; destructor Destroy; override; end; TForm1 = class(TForm) GroupBox1: TGroupBox; Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} { TGroupBox1 } constructor TGroupBox.Create(AOwner: TComponent); begin inherited; Label1:=TLabel.Create(Self); Label1.Parent:=Self; Label1.Left:=10; Label1.Top:=20; Label1.Caption:='Label1'; end; destructor TGroupBox.Destroy; begin Label1.Free; inherited; end; { TForm1 } procedure TForm1.Button1Click(Sender: TObject); begin Form1.GroupBox1.Label1.Caption:='Hobbit'; end; end. Пишу программы за еду. __________________ |
#7
|
|||
|
|||
![]() А использовать TFrame - это не оно?
|
#8
|
|||
|
|||
![]() Цитата:
а просто назвать этот лэйбл GroupBoxLabel1 мозгов не хватает, отсюда и рождаются такие темы |