I have some difficulties in entering some data into TGrid Cells, can someone give me some code example with commentary on how to insert data into a TGrid cell? To be more precise in C++ Builder when I'm using a StringGrid I can use
StringGrid1->Cells[1][0] = "Hello world";
which will insert in the cell of the second column of the first row the "hello world" message. How can I do the same with TGrid? And how can I use TCheckColumn? I have many diffulties because I cannot find any good documentation.
I'm looking but there is no guide on this anywhere.
TL;DR:
You need to store the data in your own data structure, and pass it to the displayed grid via the
OnGetValue
event.I found the answer in the link to MonkeyStyler provided by @nolaspeaker in the comments.
You need to store the data yourself. When a cell in your grid is displayed, the
OnGetValue(Sender: TObject; const Col, Row: Integer; var Value: TValue)
event is fired.It is up to you to implement an event handler for this, and return the data for the given cell.
For example, suppose you have a very simple grid that only shows "hello" in every cell of the first column and "world" in every cell of the second column.
Your
OnGetValue
event would look like this: