![]() The example below shows an example of setting data for each of the built in cell types, procedure TForm1.Grid1GetValue(Sender: TObject const Col, Row: Integer Since TValue is a record there is no need to ‘free’ it.Ī TValue uses generics to specify the data type to read or write. TValue, declared in the System.RTTI unit, is a record which can store any type of data, similar to a Variant, except that it is type-safe and trying to read data of the wrong type will result in an access violation. ![]() OnGetValue passes in the row and column of the cell whose data it needs and expects a TValue record to be returned containing the data. TGrid actually fetches data on demand through the OnGetValue event whenever it needs to update the display of a cell. ![]() When a grid is scrolled cells will be recycled and you will need to set new data into those recycled cells. You can set a cells data and read it back, but each grid only creates the minimum number of cells it needs to display them given the current control size and row height. TGrid does not store any data internally. The following is from my site at Setting and Getting Cell Data Since these are called repeatedly as the grid is scrolled you may want to cache your data locally. TStringGrid is simple, just use the Cells array to write and read data StringGrid1.Cells := 'Hello World' įor TGrid you need to hook OnGetValue and OnSetValue events.
0 Comments
Leave a Reply. |