Friday 15 January 2010

delphi - Triggering an event to fire on a form when an event on a frame occurs -


I have a form that has a list box, this form is also a parent in a frame that has a scrollbox in which the panel Are ready. When the user chooses the X number of items from the list box and clicks on the panel, then the panel x number is subdivided into small panels (eg if the user selects 3 items from the list box and a single on the frame Clicks on the panel, it will split itself into 3 small panels).

How many objects can we select for the panel, before each border of the panel is set (eg, a user sets the limit of 2, then selects 3 items and tries To click on a panel, the warning shows that you can not do this) When I see a warning, I want to return items to the list box so that users can choose them (as this action can not be completed. Was not a compliment).

I wrote this code to complete the code I want, the problem is that these objects are not available for me at the time of the incident (I add the form of parental for implementation Attempted section and calling it with fmSeatingAssignments.UndoSelection, but quickly discovered that the allocation of the frequency of objects is out of the scope). Process TfmSeatAssignments.UndoSelection; War I: Integer; I begin with: = 0 to FVehicleLayout.SelStudents.Count- 1 start ListBox1.Items.Add (FVehicleLayout.SelStudents [I]); End; I: = 0 for listbox 1. Calculate - 1 Start the ListBox 1. Selected [I]: = false; End; FVehicleLayout.SelStudents.Clear; End;

FVehicleLayout is a frame and a stringlist that takes the selected items (which are then removed from the list box). When I close the following code, I want to call the code mentioned above, which is on the frame:

  Process TFrameVehicleLayout.ClickEvent (Sender: Tubect); Var I, row, side: integer; Start TooManyOstrichs: = Incorrect; If SelStudents.Count & gt; 0 Then start side: = -1; I: = 0 to higher (bus.baside) bus can start. Buseside [ii] LookupPanel (Teppenal (sender), line) Then start side: = I; break; End; End; If side = 0 starts then if the SelStudents.Count & gt; VehicleLayout.fDSSeats then started vsiMessageDlg ('The number of selected students exceeded the amount allowed' + 'per line for this bus, please try again.', MtWarning, [mbok], mbok, Self.Handle); // Call exit fmSeatAssignments.Undo Selection; End; End; If the side & lt; & Gt; -1 then trow (bus.basside [side] begins. [Row] rows). Occupants.Assign (SelStudents); . Trow (Bus.BusSide [Side] .ows [line]) FreePanels; Trow (Bus.BusSide [Side] .Rows [row]) BuildPanelArray. ShowLayout; SelStudents.Clear; End; End; End;   

How to get help in getting those items in the returning list in the SelStudents will be greatly appreciated if none of these is confusing or clear, then tell me and I Demo program and full code will be posted. Thanks in advance for any help, you can give me

You only have a list of external references, you can declare a field on the frame and While forming, you can set the form to the listbox, surely you need to move the UndoSelection method in the frame with this solution.

Alternatively, if you do not want to move the method, you can declare and publish an event on the frame, and it can provide a process of parent form at construction time. Perhaps something looks like this:

  type TFrameVehicleLayout = class (TFrame) Private FOnUndo Selection: TNotifyEvent; Public Property On Uno Selection: Select TNotifyEvent FOnUndo Write FOnUndoSelection; End; Process TFrameVehicleLayout.ClickEvent (Sender: TObject); .. Start .. if assigned (on-or-off selection) then on-on ceiling (self); ..   

Assign property to the form:

  type TfmSeatAssignments = class (TForm) .. Personal Process OnFrameUndoSelection (Sender: TObject); Public .. var F: TFrameVehicleLayout; Start F: = TFrameVehicleLayout.Create (self); F.OnUndo Selection: = Choosing Onfame Uno; .. You can also get the parent form of the frame (`GetParentFormĂ‚¯l) 'and repeat the controls until you find a list box. Or maybe post a user message on the form that he understands. Other solutions can also be there.   

No comments:

Post a Comment