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:
# Implementation in Color Box Creation
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 here.