Форум: "Основная";
Текущий архив: 2003.06.09;
Скачать: [xml.tar.bz2];
ВнизДинамический TComboBox Найти похожие ветки
← →
Jaxtor (2003-05-27 16:17) [0]У меня есть форма, на ней динамически появляется компонент TComboBox. Как определить обработчик события OnChange для этого
ComboBox?
← →
NickBat (2003-05-27 16:20) [1]myComboBox:=TComboBox.Create(self);
myComboBox.OnChange:=myOnChange;
Предварительно описываешь процедуру myOnChange/
← →
Jaxtor (2003-05-27 16:21) [2]Thanks
← →
Skier (2003-05-27 16:21) [3]http://www.delphimaster.ru/cgi-bin/faq.pl?look=1&id=988625051&n=19
← →
jack128 (2003-05-27 16:24) [4]ручками написать
Tform1 = class(Tform)
procedure ComboBox1Change(Sender: TObject);end;//это написать руками
procedure TForm1.ComboBox1Change(Sender: TObject);
begin
//Пишешь обработчик
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
with Tcombobox1.Create(Self) do //создаешь комбобокс
OnChange := ComboBox1Change // и назначаешь обработчик
end;
← →
yaJohn (2003-05-27 16:31) [5]MyComboBox.OnChange := Form1.Button1Click;
← →
Jaxtor (2003-05-27 17:33) [6]LabelVariable:=TLabel.Create(Self);
LabelVariable.Parent:=Self;
LabelVariable.Left:=10;
LabelVariable.Top:=10;
LabelVariable.Name:="Label1";
LabelVariable.Caption:="xxxx";
procedure TParametersForm.OnCategoryComboBoxChange(Sender:TObject);
begin
If (ParametersForm.FindComponent("Label1") = nil) then showmessage("");
end;
Почему возникает AccessVialation в TParametersForm.OnCategoryComboBoxChange?
← →
Jaxtor (2003-05-27 17:42) [7]procedure TParametersForm.OnCategoryComboBoxChange(Sender:TObject);
begin
If not (Application.FindComponent("Label1") = nil) then showmessage("");
end;
Почему нет компонента Label1?
← →
Skier (2003-05-27 17:44) [8]
> Почему нет компонента Label1?
If not ( Application.FindComponent("Label1") = nil) then showmessage("");
← →
Jaxtor (2003-05-27 17:50) [9]>Skier Да, компонент Label1 на форме ParametersForm есть. Он создается динамически. А FindComponent находит его как Nil. Почему?
← →
Skier (2003-05-27 17:52) [10]procedure TParametersForm.OnCategoryComboBoxChange(Sender:TObject);
begin
If FindComponent("Label1") <> nil then showmessage("");
end;
← →
Jaxtor (2003-05-27 17:53) [11]Thanks
← →
Palladin (2003-05-27 17:54) [12]
> Jaxtor © (27.05.03 17:42)
патамушта что ты его не там ищешь
← →
jack128 (2003-05-27 17:54) [13]
> Jaxtor © (27.05.03 17:50)
Ты не понял -)) Skier © хотел сказать, что нужно не у Application"a искать , а у ParametersForm, то есть так:
procedure TParametersForm.OnCategoryComboBoxChange(Sender:TObject);
begin
If not (FindComponent("Label1") = nil) then showmessage("");
end;
← →
Smashich (2003-05-27 17:56) [14]2Jaxtor © (27.05.03 17:50)
1. function FindComponent(const AName: string): TComponent; Indicates whether a given component is owned by the component. тоесть Form1.FindComponent("Label1")<>nil означает что Label1 принадлежит Form1.
2. If not ( Application.FindComponent("Label1") = nil) then showmessage("");
← →
Jaxtor (2003-05-27 17:57) [15]If FindComponent("Label1") <> nil then RemoveComponent("Label1") ;
Почему ошибка?
← →
Skier (2003-05-27 17:59) [16]>Jaxtor © (27.05.03 17:57)
Ты параметры RemoveComponent внимательно изучал ?!
Это уже просто флейм...
RemoveComponent(FindComponent("Label1"))
← →
Sandman25 (2003-05-27 18:02) [17]ИМХО разработчики могли бы назвать FindComponentByName, чтобы людей не путать.
← →
Jaxtor (2003-05-27 18:02) [18]If FindComponent("Label1") as TComponent <> nil then RemoveComponent(FindComponent ("Label1")) ;
Не удаляется он на форме...
← →
Palladin (2003-05-27 18:02) [19]это уже наглость
← →
Jaxtor (2003-05-27 18:26) [20]>Palladin Правда, не удаляется он, Label1 то.
← →
Palladin (2003-05-27 18:28) [21]у тебя вообще программа компилируется?
← →
Jaxtor (2003-05-27 18:30) [22]>Palladin Да! Даже Exception не возникает:))
← →
Palladin (2003-05-27 18:32) [23]давай сюда реальный код а не его воспроизведение
← →
Jaxtor (2003-05-27 18:36) [24]
procedure TParametersForm.OnCategoryComboBoxChange(Sender:TObject);
var i:integer;
begin
If FindComponent("Label1") as TComponent <> nil then RemoveComponent(FindComponent ("Label1")) ;
end;
procedure TParametersForm.FormCreate(Sender: TObject);
var LabelVariable:TLabel;
EditVariable: TEdit;
ComboBoxVariable: TComboBox;
CheckBoxVariable: TCheckBox;
GroupBoxVariable: TGroupBox;
RadioButtonVariable: TRadioButton;
ProductTypeID,VNDNameID:integer;
Description:String;
Prop_Descr_Loop,n,LabelTopPosition:integer;
PropDescrArray, PropTypeArray:array[0..100] of string;
PropertiesArray: array[1..20] of integer;
FieldIDArray: array[1..20] of string;
DescriptionArray: array[1..20] of string;
DescriptionPosition: integer;
CheckBoxNameShift,CheckBoxShift:integer;
RadioButtonNameShift,RadioButtonShift:integer;
GroupBoxWidth:integer;
DescriptionCount:integer;
i,k:integer;
begin
LabelVariable:=TLabel.Create(Self);
LabelVariable.Parent:=Self;
LabelVariable.Left:=10;
LabelVariable.Top:=10;
LabelVariable.Name:="Label1";
LabelVariable.Caption:="
← →
Palladin (2003-05-27 18:42) [25]меня не столько озадачило что у тебя компонент не удаляется, сколько: почему же она вообще компилируется...
а это...
If Assigned(FindComponent("Label1"))<>nil then RemoveComponent(FindComponent ("Label1")) ;
← →
Palladin (2003-05-27 18:43) [26]мля
If Assigned(FindComponent("Label1")) then RemoveComponent(FindComponent("Label1")) ;
← →
Jaxtor (2003-05-27 18:46) [27]Palladin> Incompatible types...
← →
Jaxtor (2003-05-27 18:48) [28]If Assigned(FindComponent("Label1")) then RemoveComponent(FindComponent("Label1")) ;
Не удаляется...
← →
Palladin (2003-05-27 18:51) [29]
> Jaxtor © (27.05.03 18:48)
мда... действительно...
будем действовать жестко и беспощадно
If Assigned(FindComponent("Label1")) then FindComponent("Label1").Free ;
← →
Sandman25 (2003-05-27 18:52) [30]Palladin
Тогда уже просто FindComponent("Label1").Free;
← →
Jaxtor (2003-05-27 18:52) [31]Работает!
← →
Palladin (2003-05-27 18:54) [32]
> Sandman25 © (27.05.03 18:52)
да, только что хотел написать...
← →
Skier (2003-05-27 19:02) [33]А теперь вопрос на засыпку : какой во всём этом смысл ? :)
← →
Palladin (2003-05-27 19:07) [34]
> Skier © (27.05.03 19:02)
:) ну видимо что бы когда изменился text у categorycombobox label1 удалися с формы
← →
Palladin (2003-05-27 19:08) [35]сюда веселые люди заходят и с серьезными намеряниями просят помочь им сделать глупость...
ну что я... зверь чтоли? :))
← →
Skier (2003-05-27 19:08) [36]весьма мудро ! :)
Страницы: 1 вся ветка
Форум: "Основная";
Текущий архив: 2003.06.09;
Скачать: [xml.tar.bz2];
Память: 0.51 MB
Время: 0.01 c