Delphi What Is The The DelphiVCL Sender Property?

FireWind

Свой
Регистрация
2 Дек 2005
Сообщения
1,957
Реакции
1,199
Credits
4,009
What Is The The DelphiVCL Sender Property?
By Muhammad Azizul Hakim December 22, 2021

The Sender property specifies which component notifies the change link object of changes.

We use Sender to access the component that has changed.

Here is a working example of the implementation of Sender property in DelphiVCL:
Python:
# Implementation in Color Box Creation
def ColorChangeHandler(Sender):
   shpRectangle.Brush.Color = clbSelect.Selected
 
 
# Implementation in Draw Grid Creation
def grdTestDrawCell(Sender, Col, Row, Rect, State):
    if gdSelected in State:
        Sender.Canvas.Brush.Color = clBlue # 0x00ff0000 # blue
        Sender.Canvas.TextRect(Rect, Rect.Left+2, Rect.Top+2, "%d @ %d" % (Col, Row))
 
def grdTestSelectCell(Sender, Col, Row, CanSelect):
    if Col == 2 and Row == 2:
        CanSelect.Value = False
 
grdTest.OnDrawCell = grdTestDrawCell
grdTest.OnSelectCell = grdTestSelectCell
Using the Sender property allows us to create better abstractions in our code so that we do not refer to a specific component directly.

See the much longer complete code Для просмотра ссылки Войди или Зарегистрируйся.