Introduction to Delphi xe2 firemonkey (43)-control basics: tstringgrid and tgrid

Source: Internet
Author: User
Tstringgrid and tgrid are inherited from tcustomgrid. The differences are as follows:
1. Their column objects are tstringcolumn and tcolumn;
2. tstringgrid has more cells [] attributes than tgrid.

Because tgrid does not have the "cells []" attribute, it is not convenient to use for the moment. I used this attribute when trying to obtain the current unit value.Code:
(Grid1.columns [grid1.columnindex]. cellcontrolbyrow (grid1.selected) as ttextcell). Text

Tstringgrid test:

{Set stringgrid1 during design and fill data during runtime} procedure tform1.formcreate (Sender: tobject); var I, C, R: integer; begin stringgrid1.alternatingrowbackground: = true; condition: = true; for I: = 0 to 5 do // adding columns from design is easier than this begin with tstringcolumn. create (Self) Do begin parent: = stringgrid1; width: = stringgrid1.clientwidth/6; end; stringgrid1.rowcount: = 20; for C: = 0 to stringgrid1.columncount-1 do for R: = 0 to stringgrid1.rowcount-1 do stringgrid1.cells [C, R]: = format ('% d, % d', [C, R]); end; {Get current unit value} procedure tform1.button1click (Sender: tobject); begin showmessage (stringgrid1.cells [stringgrid1.columnindex, stringgrid1.selected]); end;
Member Overview:
{Tcustomgrid} public constructor create (...); override; // destructor destroy; override; // function columnbyindex (...): tcolumn; // obtain the column object function columnbypoint (...) based on the index (...): tcolumn; // obtain the column object function rowbypoint (...) based on the position (...): integer; // obtain the row number procedure addobject (...) based on the position (...); override; // property toprow: integer ...; // obtain the visible row number property visiblerows: integer ...; // obtain the total number of visible rows property columncount: integer ...; // Number of columns (also read-only) Property columnindex: integer ...; // obtain or set the column index property columns [index: integer]: tcolumn ...; // obtain the property rowcount: integer of the column object by means of array index ...; // number of rows (read/write) Property selected: integer ...; // The current row number property ongetvalue: tongetvalue ...; // property onsetvalue: tonsetvalue ...; // published property stylelookup; // property alternatingrowbackground: Boolean ...; // whether the alternate background is used; default value: false property canfocus default true; // property disablefocuseffect default true; // whether to cancel the focus effect property rowheight: single ...; // Row Height property showselectedcell: Boolean ...; // whether to display the unit selection effect. The default value is true property showvertlines: Boolean ...; // whether to display the vertical grid property showhorzlines: Boolean ...; // whether to display the property showheader: Boolean ...; // whether the table header property readonly: Boolean ...; // read-only or not; default value: false property taborder; // property onedititingdone: tonedititingdone ...; // end; {tgrid} tgrid = Class (tcustomgrid) published property rowcount; // property ongetvalue; // property onsetvalue; // end; {tstringgrid} public property cells [ACOl, Arow: integer]: String ...; // published property rowcount; // end;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.