Recent

Author Topic: [Solved]How to identify the parent tab sheet for an textbox  (Read 453 times)

Wilko500

  • Full Member
  • ***
  • Posts: 108
I have a settings form containing a page control with many tabs, each have many textboxes for settings. I use the following code to determine if a settings value is changed so that a save button can be enabled/disabled and perform other actions.  It would be useful if I could identify the name or index of the active tab sheet and pass that to my ValidateSettings procedure. I can't find a property that Sender has available like the "Name" or "Text" that I currently use.

Code: Pascal  [Select][+][-]
  1. Procedure TfrmSettings.txtPvUploadStartDelayEditingDone(Sender: TObject);
  2. Begin
  3. With TEdit(Sender) Do
  4.   Begin
  5.   ValidateSettings(Name, Text)
  6. End;{With}
  7. End;{Procedure}  
« Last Edit: July 21, 2024, 01:13:32 pm by Wilko500 »
MacBook Pro mid 2015 with OS Monterey 12.7.6
FPC 3.3.1 Lazarus 3.99
FPC 3.2.2 Lazarus 3.4

Bart

  • Hero Member
  • *****
  • Posts: 5467
    • Bart en Mariska's Webstek
Re: How to identify the parent tab sheet for an textbox
« Reply #1 on: July 21, 2024, 12:51:24 pm »
Check the parent of "TextBox" (if you put it directly on a TTabSheet).

Bart

Wilko500

  • Full Member
  • ***
  • Posts: 108
Re: How to identify the parent tab sheet for an textbox
« Reply #2 on: July 21, 2024, 01:13:14 pm »
I was puzzled at first with your reply.  References to Parent were giving me access violations. In VB6 I did something like txtBox.Parent but it appears that Parent is a control and can be references without being explicably referenced.  then I did this and it gets what I needed.

Code: Pascal  [Select][+][-]
  1.   ShowMessage(Parent.Name);   /code]
  2.  
  3. Thank you.  I like it when solution are simple.  
MacBook Pro mid 2015 with OS Monterey 12.7.6
FPC 3.3.1 Lazarus 3.99
FPC 3.2.2 Lazarus 3.4

 

TinyPortal © 2005-2018