Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8270531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:35:34+00:00 2026-06-08T06:35:34+00:00

I have 2 controls on a form, TCheckBox and TEdit. I want to use

  • 0

I have 2 controls on a form, TCheckBox and TEdit.

I want to use Live Binding to perform this:

  1. When TCheckBox.Checked = True, set TEdit.PasswordChar = *
  2. When TCheckBox.Checked = False, set TEdit.PasswordChar = #0

How may I write ControlExpression to achieve this? It would be great if I can avoid register custom method.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T06:35:36+00:00Added an answer on June 8, 2026 at 6:35 am

    Here’s a simple example. I couldn’t find a boolean expression evaluator so I registered a new one, and also a string-to-char converter (seems to be missing, too).

    The form:

    object Form1: TForm1
      Left = 0
      Top = 0
      Caption = 'Form1'
      ClientHeight = 282
      ClientWidth = 418
      Color = clBtnFace
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -11
      Font.Name = 'Tahoma'
      Font.Style = []
      OldCreateOrder = False
      PixelsPerInch = 96
      TextHeight = 13
      object CheckBox1: TCheckBox
        Left = 24
        Top = 24
        Width = 97
        Height = 17
        Caption = 'CheckBox1'
        TabOrder = 0
        OnClick = CheckBox1Click
      end
      object Edit1: TEdit
        Left = 24
        Top = 56
        Width = 121
        Height = 21
        TabOrder = 1
        Text = 'Edit1'
      end
      object BindingsList1: TBindingsList
        Methods = <>
        OutputConverters = <>
        UseAppManager = True
        Left = 212
        Top = 13
        object BindExpression1: TBindExpression
          Category = 'Binding Expressions'
          ControlComponent = Edit1
          SourceComponent = CheckBox1
          SourceExpression = 'iif(Checked, '#39'*'#39', '#39#39')'
          ControlExpression = 'PasswordChar'
          NotifyOutputs = True
          Direction = dirSourceToControl
        end
      end
    end
    

    and the code:

    unit Unit1;
    
    interface
    
    uses
      Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
      Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Data.Bind.EngExt, Vcl.Bind.DBEngExt, System.Rtti,
      Vcl.Bind.Editors, Data.Bind.Components, System.Bindings.Outputs;
    
    type
      TForm1 = class(TForm)
        CheckBox1: TCheckBox;
        Edit1: TEdit;
        BindingsList1: TBindingsList;
        BindExpression1: TBindExpression;
        procedure CheckBox1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;
    
    var
      Form1: TForm1;
    
    implementation
    
    {$R *.dfm}
    
    uses
      System.TypInfo,
      System.Bindings.EvalProtocol,
      System.Bindings.Methods;
    
    resourcestring
      sIifArgError = 'Expected three variables for Iif() call';
      sIifExpectedBoolean = 'First argument to Iif() must be a boolean';
    
    function MakeIif: IInvokable;
    begin
      Result := MakeInvokable(
        function(Args: TArray<IValue>): IValue
        var
          V: IValue;
          B: Boolean;
        begin
          if Length(Args) <> 3 then
            raise EEvaluatorError.Create(sIifArgError);
          V := Args[0];
          if (V.GetType^.Kind <> tkEnumeration) or (V.GetType^.Name <> 'Boolean') then
            raise EEvaluatorError.Create(sIifExpectedBoolean);
    
          B := V.GetValue.AsBoolean;
          if B then
            Result := TValueWrapper.Create(Args[1].GetValue)
          else
            Result := TValueWrapper.Create(Args[2].Getvalue);
        end
      );
    end;
    
    procedure TForm1.CheckBox1Click(Sender: TObject);
    begin
      BindingsList1.Notify(CheckBox1, 'Checked');
    end;
    
    initialization
      TBindingMethodsFactory.RegisterMethod(TMethodDescription.Create(MakeIif, 'iif', 'iif', '', True, '', nil));
      TValueRefConverterFactory.RegisterConversion(TypeInfo(string), TypeInfo(Char),
        TConverterDescription.Create(
          procedure(const I: TValue; var O: TValue)
          var
            S: string;
          begin
            S := I.AsString;
            if Length(S) = 1 then
              O := S[1]
            else
              O := #0;
          end,
          'StringToChar', 'StringToChar', '', True, '', nil));
    
    finalization
      TValueRefConverterFactory.UnRegisterConversion('StringToChar');
      TBindingMethodsFactory.UnRegisterMethod('iif');
    
    end.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 4 numeric up down controls on a form. They are set to
I have a form with some controls. (Actually, this is a sort of ongoing
I have a form with several groupboxes, each containing controls several checkboxes. I want
I have a form with some controls (extJs and ASP) like this: <ext:ComboBox ID=Countries
I want to auto resize my windows form controls on fullscreen. I use tableLayoutPanel
I have a Form with multiple different controls like ComboBox , TextBox and CheckBox
I have several controls on my form and on changed event the logic entity
When I have many controls on a Form (i.e. Label, Button etc) that do
When I have many controls on a Form (i.e. Label, Button etc) that do
I have few controls (Label, Custom Textbox, Datagridview) docked on a form. When I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.