Hello, there is a question. In general, there is Memo1 and DrawGrid1. DrawGrid1 has 5 columns and 5 rows. In memo text:

00010 10100 00100 01001 10010 

In general, it has 5 characters (1 or 0) and five lines with such characters ... So each line in Memo is responsible for a line in DrawGrid. I need to attach one number to each cell in DrawGrid and paint over it, that is, the first line is DrawGrid = first line of Memo -> In Memo, we have 01100, and the condition for each cell, if 0, then white, if 1 then black. Should get in DrawGrid cells: white black black white white. And so for each line ...

    1 answer 1

    I did it:

     procedure TForm1.DrawGrid1DrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState); Var Str: String; i, j, n, len: Byte; begin N:=Memo1.Lines.Count-1; For i:=0 To N Do Begin Str:=Memo1.Lines.Strings[i]; Len:=Length(Str); For j:=1 To Len Do Begin If (Str[j]='0') Then With DrawGrid1.Canvas Do Begin Brush.Color:=clWhite; Font.Color:=clBlack; FillRect(DrawGrid1.CellRect(j-1, i)); TextOut(DrawGrid1.CellRect(j-1, i).Left+2, DrawGrid1.CellRect(j-1, i).Top+2, '0'); End Else If (Str[j]='1') Then With DrawGrid1.Canvas Do Begin Brush.Color:=clBlack; Font.Color:=clWhite; FillRect(DrawGrid1.CellRect(j-1, i)); TextOut(DrawGrid1.CellRect(j-1, i).Left+2, DrawGrid1.CellRect(j-1, i).Top+2, '1'); End Else With DrawGrid1.Canvas Do Begin Brush.Color:=clBlack; Font.Color:=clWhite; End; If (j>=DrawGrid1.ColCount) Then Break; End; If (i>=DrawGrid1.RowCount) Then Break; End; end; 

    And when you click on the button, you need to write a line:

     DrawGrid1.Repaint; 

    I propose to do more checking when the user enters characters into the Memo (write the OnKeyPress event handler).