Help with processing Event for the component created in the RunTime mode.
Posted: Sat 26 Jan 2008 16:53
Hi all,
Can anyone help me out with the following problem.
I create the following Form elements (TDBGridEh, TMyDataSource, TMyQuery) in the RunTime mode.
Then, using Query, I fill in created tables. One column in each table gets populated using PickList. Here is the actual problem. How would I go about processing the Event, when the user picks any value from the DropDownBox for the table created in the RunTime mode?
Thanks in advance for any help
Can anyone help me out with the following problem.
I create the following Form elements (TDBGridEh, TMyDataSource, TMyQuery) in the RunTime mode.
Then, using Query, I fill in created tables. One column in each table gets populated using PickList. Here is the actual problem. How would I go about processing the Event, when the user picks any value from the DropDownBox for the table created in the RunTime mode?
Code: Select all
procedure TFRM_Work_Shedule.FormCreate(Sender: TObject);
var TableClass, SourceClass, QueryClass: TControlClass;
Work_Shedule_Table, Work_Shedule_DataSource, Work_Shedule_Query, Doctors_Query: TControl;
i, j, table_width, table_coordinate, cabs_number: Integer;
selecting_SQL, create_table_SQL: String;
begin
...
i:=0;
table_coordinate:=0;
TableClass:=TControlClass(TDBGridEh);
SourceClass:=TControlClass(TMyDataSource);
QueryClass:=TControlClass(TMyQuery);
while i<cabs_number do
begin
for j:=1 to 2 do
begin
Work_Shedule_Table:=TableClass.Create(WorkShedule_Doctors_SBox);
Work_Shedule_Table.Parent:=WorkShedule_Doctors_SBox;
Work_Shedule_DataSource:=SourceClass.Create(WorkShedule_Doctors_SBox);
Work_Shedule_Query:=QueryClass.Create(WorkShedule_Doctors_SBox);
Doctors_Query:=QueryClass.Create(WorkShedule_Doctors_SBox);
TMyDataSource(Work_Shedule_DataSource).DataSet:=TMyQuery(Work_Shedule_Query);
TDBGridEh(Work_Shedule_Table).DataSource:=TMyDataSource(Work_Shedule_DataSource);
TDBGridEh(Work_Shedule_Table).TitleLines:=2;
TDBGridEh(Work_Shedule_Table).Flat:=true;
TDBGridEh(Work_Shedule_Table).Height:=WorkShedule_Doctors_SBox.Height;
TDBGridEh(Work_Shedule_Table).Width:=150;
table_width:=TDBGridEh(Work_Shedule_Table).Width;
TDBGridEh(Work_Shedule_Table).Left:=table_coordinate;
TDBGridEh(Work_Shedule_Table).AutoFitColWidths:=true;
TMyQuery(Doctors_Query).Connection:=Data_Module.RBase_Connection;
TMyQuery(Doctors_Query).SQL.Clear;
TMyQuery(Doctors_Query).SQL.Add('SELECT * FROM doctorsref');
TMyQuery(Doctors_Query).Execute;
TDBGridEh(Work_Shedule_Table).Columns.Add.FieldName:='work_time';
TDBGridEh(Work_Shedule_Table).Columns.Add.FieldName:='doctor_name';
while not TMyQuery(Doctors_Query).Eof do
begin
TDBGridEh(Work_Shedule_Table).Columns.Items[1].PickList.Add(TMyQuery(Doctors_Query).FieldByName('doc_lname').AsString);
TMyQuery(Doctors_Query).Next;
end;
... ^^^^^^^^^^^^^^^^^^^^^^^^^^^'doctor_name' column Event
end;
