Jump to content

How to access controls like pointers in delphi?


Recommended Posts

  • Administrators

You can also use ForEach:

  var EditBoxCount: Integer := 0;
  Self.ForEach(function  (const Child: TW3TagContainer): TEnumResult
    begin
      if Child is TW3EditBox then begin
        inc(EditBoxCount);
        TW3EditBox(Child).Text:=IntToStr(EditBoxCount);
      end;
      result:=erContinue;
    end);

 

Link to post
Share on other sites

Thank you for your replies. By your help i figured out a solution. Firts i gave a tagValue for the editboxes i want to access directly. Then:

  var editIndexArray: array [1..100] of integer;
  var n: integer=0;
  for var i := 0 to self.getChildCount - 1 do
    if self.getChildObject(i) is TW3EditBox then  begin
      if (TW3EditBox(self.getChildObject(i)).TagValue=2) then begin
        n:=n+1;
        editIndexArray[n]:=i;
      end;
    end;

  TW3EditBox(self.getChildObject(editIndexArray[1])).Text:='some text';

____________________________

Thiw way i can directly access an editbox with [...]. Thank you again.

Link to post
Share on other sites
  • Administrators

@Huseyin SEKER Here's a simpler version that does the same. It collects the editboxes to an array that you can access directly. Makes the code simpler and more robust. Also note that you don't have to declare the size of the array.

var editBoxes: array of TW3EditBox;
  Self.ForEach(function(const Child: TW3TagContainer): TEnumResult
    begin
      if (Child is TW3EditBox) and (TW3EditBox(Child).TagValue=2) then editBoxes.Add(Child);
      result:=erContinue;
    end);

editBoxes[1].Text:='some text';

 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...