Good code samples for cxGrid Part2

- CxGrid summary function
① Set OptionsView-Footer to True to display the footer. ② The Summary tab of CxGrid defines the column and field names to be summarized and the summary method, the Footer tab defines a single summary, and Default For Groups defines a summary by group. OptionsView-GroupFooters is set to gfAlwaysVisible to display group summary. The interface is shown in the figure after setting.
① Set OptionsView-Footer to True to display the footer. ② The Summary tab of CxGrid defines the column and field names to be summarized and the summary method, the Footer tab defines a single summary, and Default For Groups defines a summary by group. OptionsView-GroupFooters is set to gfAlwaysVisible to display group summary. The interface is shown in the figure after setting.


- CxGrid style settings When Kind is set, NativeStyle must be set to False. If SkinName is specified, the Kind property is invalid.

The picture below is the effect after setting skinname to MoneyTwins

3. Import various formats
procedure TForm1.btn1Click(Sender: TObject);
begin
cxGridExportLink.ExportGridToHTML('d:\test.html',cxgrd1);
cxGridExportLink.ExportGridToXML('d:\test.xml',cxgrd1);
cxGridExportLink.ExportGridToExcel('d:\test.xls',cxgrd1);
cxGridExportLink.ExportGridToText('d:\test.txt',cxgrd1);
end;
4.Take the value of a cell
Cxgrid.DataController.Values[i,j]
5.Column operation, after selecting the CxGrid control, click “Customize” to create a new column, select the newly created column in the Columns collection, and select the properites property to set the display form of the column. Here are a few commonly used
① When Properties select CheckBox, a check box is displayed in this column, as follows:

Determine whether to select if Cxgrid.DataController.Values[i,j]=’1’ select
② Properties select ButtonEdit, and set the following properties to the property editor of the column to add button items to the Buttons property. For the button item settings, you can set the kind property to define the button style; the ViewStyle property is set to vsButtonsOnly, and Options-ShowEditButton is set to isebAlways. You can write click events as follows:
procedure TForm1.cxgrdbtblvwGrid1DBTableView1Column1PropertiesButtonClick(
Sender: TObject; AButtonIndex: Integer);
begin
ShowMessage('aaa');
end;
③ ImageComboBox can be associated with an imagelist to display pictures. The effect after associating the imagelist as follows.

6.Dynamically add columns and record rows
var
Column: TcxGridColumn;
i:integer;
acount:integer;
begin
Column:= cxgrd1TableView1.CreateColumn;
Column.Caption := 'Test ';
cxgrd1TableView1.DataController.AppendRecord;
cxgrd1TableView1.DataController.Values[0, 0] := 'ABC ';
cxgrd1TableView1.DataController.Post;
//Add multiple records
for i:=1 to 4 do
begin
acount:=cxgrd1TableView1.DataController.RecordCount;
cxgrd1TableView1.DataController.AppendRecord;
cxgrd1TableView1.DataController.Values[acount, 0] :=IntToStr(i*1);
cxgrd1TableView1.DataController.Post();
end;
end;
//Delete Record
cxgrd1TableView1.DataController.DeleteRecord(0);
end;