Sie sind auf Seite 1von 66

Brief introduction: cxGrid the bottom right cxGrid1Level1 is the Grid table layer a multi-cxGrid, which is equivalent to a collecti

Function and cxGrid1Level1 the right cxGrid1DBTableView1 of DBGrid equivalent. Right-click cxGrid1 can add a cxGrid1Level2 r

cxGrid1Level2 can choose the Create View, Add level or Delete Level. The Add level can increase sub-Level, Create View

Which can choose a lot of different general category of View. Among


1) DB Table and View database connection, similar to the more general DBGrid, it is more than DBGrid mouse button can be us

Query function;

2) DB Banded Table can be achieved, for example:


---------------------------------
|1|2|
---------------------------------
| Field | Field | Field | Field |
And other similar functions;
3) DB Card View provides the functionality of the card by the display data, such as management of personnel files;
4) Other enumerate.

Some use:
1) the pictures and MEMO example:
Dragged into a cxGrid1, Table1, DataSource1. The Table1 DatabaseName is set to DBDEMOS TableName Set biolife.db,

The Active Set TrueataSource1 DataSet as DataSource Table1; in cxGrid1DBTableView1 DataController

To set to DataSource1 Create All Columns; double-click cxGrid1, in the pop-up window; right-click cxGrid1DBTableView1 selecti

cxGrid1DBTableView1Notes, and cxGrid1DBTableView1Graphic, they Properties property is set to BlobEdit; look at the operatio

Results. Then cxGrid1DBTableView1Graphic Properties property is set to Image, and then Properties Stretch is set to True,

The cxGrid1DBTableView1-> optionsview-> CellAutoHeight is set to True, look at the results.

2) how to make "Drag a column here to group by that column" does not show
Solution: Click cxGrid1 cxGrid1DBTableView1
= False to Note: in cxGrid1DBTableView1-> optionsview-> groupbybox: the inside the OptionsView many properties may often

English of of 3) GroupPanel above [Drag a column header to group by that column] how can be changed to Chinese?
Solution: The easiest way is TcxGridTableView.OnCustomDrawPartBackground availability OnCustomDrawGroupCell:

The procedure TForm1.cxGrid1DBTableView1CustomDrawPartBackground (


Sender: TcxGridTableView; ACanvas: TcxCanvas;
AViewInfo: TcxCustomGridCellViewInfo; var ADone: Boolean);
begin
AViewInfo.Text: = 'Dynamic settings the GroupBox display content';
ACanvas.FillRect (AViewInfo.Bounds);
end;

4) How to achieve the following functions:


+ Finance Department
+ Raw material warehouse
+ Finished products warehouse
+ Press shop
+ Software Development
This is the name of the department, click the plus sign on the staff of the department can be displayed.
Solution: In fact, this is a master from the table 1: Fill out the main table keyfieldnames
2: Fill out the keyfieldnames Table
3: Fill out from the table detaikeyfieldNames the masterkeyfieldnames
4: according to the field associated with the main table from a data source for a certain sort Note: other places to set the main
asterfield will not display data! If the two cxGrid the master-slave relationship, so that the set is very OK.

5) statistical functions
Solution: cxGrid1DBTableView1-> optionsview-> Footer set to True
cxGrid1DBTableView1-& gtataController-> Summary set FooterSummaryItems can

6) similar PageControl display


Solution: add a Level, the is set to dtpTop in cxGrid1-> RootLevelOptions-& gtetailTabsPosition, then the appropriate settings cx

To be continued. . . . . . . . .

These are some of the problems encountered with cxGrid time, I summed up the part, there are many issues to address. Here

7) How to set the left column, can not scroll?


Solution: DB Banded Table can only be achieved,
To establish Band0, Band1 in cxGrid1DBBandedTableView
Band 0 the fixed = tfLeft of
The Band1 fixed = tfnone
Field is set to lock BandIndex = 0, other 1, OK.

8) How to achieve, such as Excel, grid = G14 + G15 + G16 this function
Solution: To give a simple example: Label1.Caption: = cxGrid1DBTableView1.DataController.Values ??[2,

3] + cxGrid1DBTableView2.DataController.Values ??[1, 1] + cxGrid1DBTableView3.DataController.Values ??[1, 1];


So different cxGrid1DBTableView data to grid, so that you do in Excel grid = G14 + G15 + G16 similar functionality.

9) right click cxGrid1DBBandedTableView1 menu the Edit Layout what is the use, how to use?
Solution: You can drag the field, side by side can be dragged into layering (layers), drag the arrow will show, that can drag a field
To the uppermost, you can make the the recording Click packet field. Click one of the fields above there will be a small triangle

The role of the small triangle in the operational phase, the data will be in accordance with this field rise or fall sort.
There is also a Set as Default role is to keep the current TableView parameters, under this new TableView will be the last remai
10) How the cxGrid data import to EXCEL, HTML, XML and TEXT
Solution: This problem is easier than ever with cxGrid
uses
cxExportGrid4Link;

procedure TForm1.Button1Click (Sender: TObject);


begin
ExportGrid4ToEXCEL ('d :/ wang.xsl', cxGrid1, True, True);
ExportGrid4ToTEXT ('d :/ wang.txt', cxGrid1, True, True);
ExportGrid4ToXML ('d :/ wang.xml', cxGrid1, True, True);
ExportGrid4ToHTML ('d :/ wang.html', cxGrid1, True, True);
end;

11) how to meet the conditions of data display different colors?


Solution:
var
AYellowStyle: TcxStyle;

to procedure TForm1.FormCreate (Sender: TObject);


begin
/ / Line color
AYellowStyle: = TcxStyle.Create (Self);
AYellowStyle.Color: = $ 0080FFFF;
AYellowStyle.TextColor: = clMaroon;
end;

The procedure TForm1.cxGrid1DBBandedTableView1StylesGetContentStyle (


Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord;
AItem: TcxCustomGridTableItem; out AStyle: TcxStyle);
begin
if ARecord.Values ??[cxGrid1DBBandedTableView1Lengthcm.Index] <81 then
AStyle: = AYellowStyle;
end;

Here cxGrid1DBBandedTableView1Lengthcm.Index less than 81 yellow

Question 12) from the outset TXT file into cxGrid?


Solve: procedure CustomizeColumns To;
procedure LoadData;
The procedure TForm1.CustomizeColumns;
const
cDistance = 1;
cRadius = 5;
The cPeriod 4;
cPstring = 0;
var
I: Integer;
begin
DecimalSeparator: = '';
with cxGrid1TableView2 do
for I: = 0 to ColumnCount - 1 do
if I in [cDistance, cRadius] then
Columns [I]. DataBinding.ValueTypeClass: = TcxIntegerValueType / / 1,5 as Integer
else
if I in [cPstring, cPeriod] then
Columns [I]. DataBinding.ValueTypeClass: = TcxStringValueType / / 0,4 as the String
else
Columns [I]. DataBinding.ValueTypeClass: = TcxFloatValueType ;/ / Float
end;

The procedure TForm1.LoadData;


const
AFileName = 'balance sheet. TXT';
AHeaderLineCount =;

var
ARecords, AValues: TStringList;
I: Integer;

to procedure InitRecord (const Str: string);


var
J: Integer;
V: Variant;
begin
AValues.CommaText: = Str;
for J: = 0 to AValues.Count - 1 do
the if AValues.Strings [J] <> '-' THEN
begin
V: = AValues.Strings [J];
the IF NOT VarIsNull (V) then
cxGrid1TableView2.DataController.Values ??[i, j]: = V;
end;
end;
begin
if not FileExists (AFileName) then
raise Exception.Create ('Data file not found');

ARecords: = TStringList.Create;
AValues: = TStringList.Create;

with ARecords do
try
LoadFromFile (AFileName);
cxGrid1TableView2.BeginUpdate;
cxGrid1TableView2.DataController.RecordCount: = Count - AHeaderLineCount;
for I: = 0 to Count - (AHeaderLineCount + 1) do
InitRecord (Strings [I + AHeaderLineCount]);
finally
cxGrid1TableView2.EndUpdate;
ARecords.Free;
AValues.Free;
end;
end;

to procedure TForm1.FormCreate (Sender: TObject);


begin
CustomizeColumns;
LoadData_Zcfz;
end;

The data in the "balance sheet. Txt" as follows:

The assets line times the number at the beginning of the end of the number of liabilities and owner's equity line number at the
-------------------------------------------------- -------
Current assets: Current liabilities: 1 0.00 0.00 2 0.00 0.00

13) How to change the color of the column?


var
AFirstColumnStyle: TcxStyle;

to procedure TForm1.FormCreate (Sender: TObject);


begin
/ / Column color
AFirstColumnStyle: = TcxStyle.Create (Self);
AFirstColumnStyle.Color: = clAqua;
AFirstColumnStyle.TextColor: = clBlue;
cxGrid1TableView1.Columns [1]. Styles.Content: = AFirstColumnStyle;
end;
14) Set as default the usage?
The resolve: Set as the default usage is done in order to solve the convenience of setting parameters, such as:
Even the database, change cxGrid1DBBandedTableView1-<OptionsCustomize-> ColumnFiltering to False. (This setting can be to
OK, next time you generate a new cxGrid1DBBandedTableView1 these settings and just the same. If you need to set the param

15) How to move the cursor, the corresponding text of the cell to change color?
Solution:
var
FTrackItem: TcxCustomGridTableItem;
FTrackRec: TcxCustomGridRecord;

The procedure TForm1.cxGrid1DBTableView1CustomDrawCell (


Sender: TcxCustomGridTableView; ACanvas: TcxCanvas;
AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
begin
if (AViewInfo.GridRecord = FTrackRec) and (AViewInfo.Item = FTrackItem) then
begin
ACanvas.Font.Color: = clred; / / red font
ACanvas.Font.Style: = [fsUnderline] ;/ / underlined
end;
end;

procedure TForm1.cxGrid1DBTableView1MouseMove (Sender: TObject;


The Shift: TShiftState; X, Y: Integer);
var
AHitTest: TcxCustomGridHitTest;
ATrackItem: TcxCustomGridTableItem;
ATrackRec: TcxCustomGridRecord;
begin
ATrackItem: = FTrackItem;
ATrackRec: = FTrackRec;

AHitTest: = (Sender as TcxGridSite). GridView.ViewInfo.GetHitTest (X, Y);


if AHitTest is TcxGridRecordCellHitTest then
begin
FTrackItem: = TcxGridRecordCellHitTest (AHitTest). Item;
FTrackRec: = TcxGridRecordCellHitTest (AHitTest). GridRecord;
end
else
begin
FTrackItem: = nil;
FTrackRec: = nil;
end;

if (ATrackItem <> FTrackItem) or (ATrackRec <> FTrackRec) then


begin
/ / Invalidate old cell
if ATrackRec <> nil then
ATrackRec.Invalidate (ATrackItem);
/ / Invalidate new cell
if FTrackRec <> nil then
FTrackRec.Invalidate (FTrackItem);
end;
end;

16) how to design multiple headers cxGrid?


Solution: cxGrid header can be solved as follows:
---------------------------------
|1|2|
---------------------------------
| Field | Field | Field | Field |
| The fields 5 | field 6 |
| Field | field | Field 9 |
Achieve this is very simple, you can directly drag the field names in the above is displayed, drag the arrows into the location wh

But cxGrid can not be achieved as follows multi-table form:


---------------------------------
|1|2|
---------------------------------
|3|4|5|6|
| Field 1 | field 2 |
| Field | Field | field 5 |
I do not know who can achieve such a multi-table?

17) from the table structure, the main point to open the "+" how the focus on the corresponding master table records?
Solution:
var
HitTest: TcxCustomGridHitTest;

procedure TColumnsShareDemoMainForm.tvProjectsMouseDown (Sender: TObject;


Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
/ / Note that the Sender parameter is a Site
HitTest: = (sender as TcxGridSite), GridView.ViewInfo.GetHitTest (X, Y);
/ / The point belongs to the [+] / [-] button area
if HitTest is TcxGridExpandButtonHitTest then
/ / Move focus to the record
TcxGridExpandButtonHitTest (HitTest). GridRecord.Focused: = True;
end;
769 Words? 48 views? 07-02-09? 10:34:50? High Yukun
Grid export data
Category: Delphi
Grid can be used directly export data
The ExportGrid4ToExcel function in the package cxExportGrid4Link in, export grid data to a file function
The ShellExecute function ShellAPI open file

Code:
The ExportGrid4ToExcel (AppRootDir + 'production plan instruction', grdWorkOrder True, True, True, 'xls');
try
ShellExecute (handle, nil, PChar (AppRootDir + 'production plan instruction XLS'), nil, nil, SW_SHOWNORMAL);
except
ShowMessage ('The machine is not installed EXCEL, this function must EXCEL installed on your computer in order to run!');
Abort;
end;

If you want to the exported fonts and colors, and grid use TcxStyleRepository control, build a TcxStyle, set the color and font, th

39 Words? 51 views? 07-02-07? 17:12:39? High Yukun


About the color of the grid
Category: Delphi
The procedure TForm.cxGrid1DBTableView1StylesGetContentStyle (
Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord;
AItem: TcxCustomGridTableItem; out AStyle: TcxStyle);
begin
if ARecord is TcxGridDataRow and not ARecord.Selected then
begin / / clnEngineer.Index is an integer of 1, 2, 3
if ARecord.Values ??[clnEngineer.Index] = Null then
AStyle: = sty1 / / sty1 a kid TcxStyleRepository
else if ARecord.Values ??[clnEnginneerUserID.Index] = UserId then
if (ARecord.Values ??[clnNotOddState.Index] = 'process') or
(ARecord.Values ??[clnNotOddState.Index] = 'process to assist') then
AStyle: = sty2 / / sty2 a kid TcxStyleRepository
end;
end;

Resolution AStyle two basic properties of 1 - Color 2 - TextColor


Color: the background color of the grid
TextColor: grid inside the color of the font control properties of TcxStyleRepository control

Will be able to know why to assigned to AStyle can the TcxStyleRepository a boy child!

71 Words? 71 views? 06-12-05? 18:01:32? Sun is appropriate


The elected cxgrid records, change the background color of the selected records to (default is blue)
Category: Delphi
The procedure TM7_BugManagementForm.tvQryCustomDrawCell (
Sender: TcxCustomGridTableView; ACanvas: TcxCanvas;
AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
begin
if ADone or AViewInfo.Selected then
begin
ACanvas.Font.Color: = clBlack;
ACanvas.SetBrushColor (clWhite);
end;
end;

30 Words? 86 views? 06-11-15? 16:16:47? Ling new


point of cxGrid knowledge
Category: DevExpress
Set TableView.OptionsView.HeaderAutoHeight for True, the column headings will adjust its height
Grid, select the record, when the focus is removed, not see the selected records, the solution: Modify the properties of the Tab
Record traversal selected:
with ATableView.DataController do
begin
VOldFocusedRecordIndex: = FocusedRecordIndex;

for VIndex: = 0 to ATableView.Controller.SelectedRowCount - 1 do


begin
FocusedRecordIndex: = ATableView.Controller.SelectedRows [VIndex]. RecordIndex;
AQry.UpdateObject.ExecSQL (ukInsert);
end;

FocusedRecordIndex: = VOldFocusedRecordIndex;
end;

Traverse all the records in the current view:


with ATableView.DataController do
begin
VOldFocusedRecordIndex: = FocusedRecordIndex;

for VIndex: = 0 to FilteredRecordCount - 1 do


begin
FocusedRecordIndex: = FilteredRecordIndex [VIndex];
AQry.UpdateObject.ExecSQL (ukInsert);
end;

FocusedRecordIndex: = VOldFocusedRecordIndex;
end;

The calls the TableView The DataController.Groups.FullExpand method expand all nodes
Use a custom data source, delete records, BeginUpdate, processed and then the EndUpdate, otherwise it will occasionally thro
tvProducePlan.BeginUpdate;
try
FCustomDataSource.DeleteSelectedRecord (GetSelectedIds);
finally
tvProducePlan.EndUpdate;
end;
Get the value of a column of the record selected:
function TMainForm.GetSelectedIds: TStringArray;
var
VIndex: Integer;
begin
SetLength (Result tvProducePlan.Controller.SelectedRowCount,);
for VIndex: = 0 to tvProducePlan.Controller.SelectedRowCount - 1 do
Result [VIndex]: = tvProducePlan.DataController.Values ??[tvProducePlan.Controller.SelectedRecords [VIndex]. RecordIndex, 0]
end;
Another grid based on a grid of data positioning:
procedure TMainForm.LinkFocusRecord (AParentColumn, AChildColumn: TcxGridColumn; AParentGrid, AChildGrid: TcxGridTab
var
VIndex: Integer;
VValue: String;
FocusedRecord: TcxGridFocusedRecordChangedEvent;
begin
FocusedRecord: = AParentGrid.OnFocusedRecordChanged;
AParentGrid.OnFocusedRecordChanged: = nil;
try
with AChildGrid.DataController do
begin
VValue: = GetDisplayText (FocusedRecordIndex, AChildColumn.Index);
end;

VIndex: = AParentGrid.DataController.FindRecordIndexByText (0, AParentColumn.Index, VValue, False, False, True);

if VIndex <0 then


begin
AParentGrid.DataController.ClearSelection;
Exit;
end;

AParentGrid.DataController.FocusedRecordIndex: = VIndex;
AParentGrid.DataController.SyncSelectionFocusedRecord;
finally
AParentGrid.OnFocusedRecordChanged: = FocusedRecord;
end;
end;
The TableView FocusedRecordChanged event indicates the current focused recording change the use TcxGridTableView.Contro

Relate

the delphi cxGrid use method


cxGrid use
The ZT: cxGrid use
Added: sharing of some use ExpressQuantumGrid cxGrid methods and experience
Of Delphi use cxGrid data set Sort Locate operation
CxGrid packet
CxGrid usage
Dev cxGrid
CxGrid Summary (continued)
cxGrid column field names
which is equivalent to a collection of PageControl

xGrid1 can add a cxGrid1Level2 right-click

e sub-Level, Create View

DBGrid mouse button can be used, you can count

nt of personnel files;

bleName Set biolife.db,

ick cxGrid1DBTableView1 selection

t to BlobEdit; look at the operation

erties Stretch is set to True,

iew many properties may often use, such as: ColumnAutoWith Navigator, etc., slowly pondering.

e changed to Chinese?
ustomDrawGroupCell:
ote: other places to set the main table structure as the display is not, such as setting the table from the Table or Query mastersource

then the appropriate settings cxGrid1Level1 and cxGrid1Level2 the Caption value.

re many issues to address. Here I would like to used cxGrid of people helped to summarize, let scholars less detours!

er.Values ??[1, 1];


milar functionality.

ow will show, that can drag a field to put


ove there will be a small triangle up or down, this

field rise or fall sort.


TableView will be the last remains of parameters.
wner's equity line number at the beginning of the end of times
meters, such as:
g to False. (This setting can be to the drop-down list of field names removed) change cxGrid1DBBandedTableView1-<OptionsView-> Naviga
me. If you need to set the parameters of a lot of the time, the Set as default useful!
g the arrows into the location where you want to display on the OK. Or Edit Layout in the right click cxGrid1DBBandedTableView1 menu can

ng master table records?


True, 'xls');

HOWNORMAL);

computer in order to run!');

cxStyle, set the color and font, this assign a TcxStyle to Content the property of TcxGridDBTableView Styles and Header on OK.
Modify the properties of the TableView, OptionsSelection-> HideSelection set to False
therwise it will occasionally throw index out of range:

ecords [VIndex]. RecordIndex, 0];

entGrid, AChildGrid: TcxGridTableView);

e, False, False, True);


he use TcxGridTableView.Controller the TopRowIndex, LeftPos Gets or sets the currently visible view line number at the top of the left positi
le or Query mastersource
bleView1-<OptionsView-> Navigator set to True. Then right-click cxGrid1DBBandedTableView1, inside the pop-up menu bar, click Set as def
DBBandedTableView1 menu can also drag and drop.
and Header on OK.
umber at the top of the left position
op-up menu bar, click Set as default.
the delphi cxGrid use method
1. Binding data method
cxGrid1DBTableView1.DataController.DataSource: = DataSource1
(2) remove the "Drag a column header here to group by that column"
Method
cxGrid1DBTableView1.OptionsView.GroupByBox set to False
Remove header lower triangular data
cxGrid1DBTableView1.Optionscustomize.columnfiltering set to False
The increased number to increase Mycount field type in the dataset inside to string
The increased display field No. mycount in CXgrid
Write for the field events
procedure Tfrm_form.ReDataSet2mycountGetText (Sender: TField;
var Text: String the; DisplayText: Boolean);
begin
Inherited;
text: = inttostr (redataset2.RecNo);
end;

The serial number bound field Mycount

5.CXgrid additional column to display a checkbox


The dataset inside to increase MySelect field type BOOLEAN

Select select in the increased CXgrid display field

Properties set the select field for the CheckBox. ReadOnly = False;
NullStyle = nssUnchecked

The procedure Tfrm_form.cxGrid1DBTableView1CellClick (


Sender: TcxCustomGridTableView;
ACellViewInfo: TcxGridTableDataCellViewInfo; AButton: TMouseButton;
AShift: TShiftState; var AHandled: Boolean);
var
Row: Integer;
begin
Inherited;

if ACellViewInfo.Item.Name = 'mycheck' then


begin
Row: = cxGrid1DBTableView1.DataController.FocusedRecordIndex;
if cxGrid1DBTableView1.ViewData.Records [Row]. Values ??[0] = True then
cxGrid1DBTableView1.ViewData.Records [Row]. Values ??[0]: = False
else
cxGrid1DBTableView1.ViewData.Records [Row]. Values ??[0]: = True;
end;
end;

procedure Tfrm_form.cxGrid1DBTableView1MouseUp (Sender: TObject;


Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
Row: Integer;
begin
Inherited;
/ / Radio
/ / For Row: = 0 to cxGrid1DBTableView1.DataController.RecordCount-1 do
/ / Begin
/ / CxGrid1DBTableView1.ViewData.Records [Row]. Values ??[0]: = False;
/ / End;
/ / Multiple choice
if cxGrid1DBTableView1.DataController.RecordCount <> 0 then
begin
Row: = cxGrid1DBTableView1.DataController.FocusedRecordIndex;

if cxGrid1DBTableView1.ViewData.Records [Row]. Values ??[0] = True then


cxGrid1DBTableView1.ViewData.Records [Row]. Values ??[0]: = False
else
cxGrid1DBTableView1.ViewData.Records [Row]. Values ??[0]: = True;
end;
end;

This article comes from programmershare.com blog, reproduced, please indicate the source:
box, remove cxgrid station head = false; at the tableview1 ptionsview groupbybox,
2 In the Grid footer SUM (column) tableview1 optionsviewfooter =-ture
Then a summary of footer.add in cxGRid1 customize .. total column kind = skSum
3 to remove cxgrid filter drop-down arrow to select tableview1.optionscustomize.columnfiltering = fasle;
The 4. CxGrid1DBTableView1 OptionView the property GroupFooters to gfAlwaysVisible and set the need to sum a column, add
You can achieve the desired function
Dev Express Lane cxGrid default numeric format with how to remove ah!
6. Double-click cxGrid, colmnum change the type options.properties.Memo
7 set in displayformat

From the Monopoly Forum

The use cxGrid some time to summarize here some of the ways to use cxGrid, I hope some help to people just getting started w

Brief introduction: cxGrid the bottom right cxGrid1Level1 is the Grid table layer a multi-cxGrid, which is equivalent to a collectio

Function and cxGrid1Level1 the right cxGrid1DBTableView1 of DBGrid equivalent. Right-click cxGrid1 can add a cxGrid1Level2 r

cxGrid1Level2 can choose the Create View, Add level or Delete Level. The Add level can increase sub-Level, Create View

Which can choose a lot of different general category of View. Among


1) DB Table and View database connection, similar to the more general DBGrid, it is more than DBGrid mouse button can be us

Query function;
2) DB Banded Table can be achieved, for example:
---------------------------------
|1|2|
---------------------------------
| Field | Field | Field | Field |
And other similar functions;
3) DB Card View provides the functionality of the card by the display data, such as management of personnel files;
4) Other enumerate.

Some use:
1) the pictures and MEMO example:
Dragged into a cxGrid1, Table1, DataSource1. The Table1 DatabaseName is set to DBDEMOS TableName Set biolife.db,

Active is set to True; the DataSource1 DataSet to DataSource Table1; the cxGrid1DBTableView1 DataController,

To set to DataSource1 Create All Columns; double-click cxGrid1, in the pop-up window; right-click cxGrid1DBTableView1 selecti

cxGrid1DBTableView1Notes, and cxGrid1DBTableView1Graphic, they Properties property is set to BlobEdit; look at the operatio

Results. Then cxGrid1DBTableView1Graphic Properties property is set to Image, and then Properties Stretch is set to True,
The cxGrid1DBTableView1-> optionsview-> CellAutoHeight is set to True, look at the results.

2) how to make "Drag a column here to group by that column" does not show
Solution: Click cxGrid1 cxGrid1DBTableView1
In cxGrid1DBTableView1-> optionsview-> groupbybox: = false to
Note: OptionsView inside many properties may often use, such as: ColumnAutoWith, Navigator, etc., slowly pondering it :)

English of of 3) GroupPanel above [Drag a column header to group by that column] how can be changed to Chinese?
Solution: The easiest way is TcxGridTableView.OnCustomDrawPartBackground availability OnCustomDrawGroupCell:

The procedure TForm1.cxGrid1DBTableView1CustomDrawPartBackground (


Sender: TcxGridTableView; ACanvas: TcxCanvas;
AViewInfo: TcxCustomGridCellViewInfo; var ADone: Boolean);
begin
AViewInfo.Text: = 'Dynamic settings the GroupBox display content';
ACanvas.FillRect (AViewInfo.Bounds);
end;

4) How to achieve the following functions:


+ Finance Department
+ Raw material warehouse
+ Finished products warehouse
+ Press shop
+ Software Development
This is the name of the department, click the plus sign on the staff of the department can be displayed.
Solution: In fact, this is a master from the table 1: Fill out the main table keyfieldnames
2: Fill out the keyfieldnames Table
3: Fill out from the table detaikeyfieldNames the masterkeyfieldnames
4: data source from the table according to a certain sort fields associated with the main table
Note: other places set up master-slave table structure as display does not come out, such as setting the table from the Table or
asterfield will not display data! If the two cxGrid the master-slave relationship, so that the set is very OK.

5) statistical functions
Solution: cxGrid1DBTableView1-> optionsview-> Footer set to True
cxGrid1DBTableView1-> DataController-> Summary set FooterSummaryItems can

6) similar PageControl display


Solution: add a Level cxGrid1-> RootLevelOptions-> DetailTabsPosition set to dtpTop, then the appropriate settings cxGrid1Leve

To be continued. . . . . . . . .

7) How to set the left column, can not scroll?


Solution: DB Banded Table can only be achieved,
To establish Band0, Band1 in cxGrid1DBBandedTableView
Band 0 the fixed = tfLeft of
The Band1 fixed = tfnone
Field is set to lock BandIndex = 0, other 1, OK.

8) How to achieve, such as Excel, grid = G14 + G15 + G16 this function
Solution: To give a simple example: Label1.Caption: = cxGrid1DBTableView1.DataController.Values ??[2,

3] + cxGrid1DBTableView2.DataController.Values ??[1, 1] + cxGrid1DBTableView3.DataController.Values ??[1, 1];


So different cxGrid1DBTableView data to grid, so that you do in Excel grid = G14 + G15 + G16 similar functionality.

9) right click cxGrid1DBBandedTableView1 menu the Edit Layout what is the use, how to use?
Solution: You can drag the field, side by side can be dragged into layering (layers), drag the arrow will show, that can drag a field

To the uppermost, you can make the the recording Click packet field. Click one of the fields above there will be a small triangle

The role of the small triangle in the operational phase, the data will be in accordance with this field rise or fall sort.
There is also a Set as Default role is to keep the current TableView parameters, under this new TableView will be the last remai

10) How the cxGrid data import to EXCEL, HTML, XML and TEXT
Solution: This problem is easier than ever with cxGrid
uses
cxExportGrid4Link;

procedure TForm1.Button1Click (Sender: TObject);


begin
ExportGrid4ToEXCEL ('d :/ wang.xsl', cxGrid1, True, True);
ExportGrid4ToTEXT ('d :/ wang.txt', cxGrid1, True, True);
ExportGrid4ToXML ('d :/ wang.xml', cxGrid1, True, True);
ExportGrid4ToHTML ('d :/ wang.html', cxGrid1, True, True);
end;

11) how to meet the conditions of data display different colors?


Solution:
var
AYellowStyle: TcxStyle;

to procedure TForm1.FormCreate (Sender: TObject);


begin
/ / Line color
AYellowStyle: = TcxStyle.Create (Self);
AYellowStyle.Color: = $ 0080FFFF;
AYellowStyle.TextColor: = clMaroon;
end;
The procedure TForm1.cxGrid1DBBandedTableView1StylesGetContentStyle (
Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord;
AItem: TcxCustomGridTableItem; out AStyle: TcxStyle);
begin
if ARecord.Values ??[cxGrid1DBBandedTableView1Lengthcm.Index] <81 then
AStyle: = AYellowStyle;
end;

Here cxGrid1DBBandedTableView1Lengthcm.Index less than 81 yellow

12) from the outset TXT file into cxGrid?


Solve: procedure CustomizeColumns To;
procedure LoadData;

The procedure TForm1.CustomizeColumns;


const
cDistance = 1;
cRadius = 5;
The cPeriod 4;
cPstring = 0;
var
I: Integer;
begin
DecimalSeparator: = '';
with cxGrid1TableView2 do
for I: = 0 to ColumnCount - 1 do
if I in [cDistance, cRadius] then
Columns [I]. DataBinding.ValueTypeClass: = TcxIntegerValueType / / 1,5 as Integer
else
if I in [cPstring, cPeriod] then
Columns [I]. DataBinding.ValueTypeClass: = TcxStringValueType / / 0,4 as the String
else
Columns [I]. DataBinding.ValueTypeClass: = TcxFloatValueType ;/ / Float
end;

The procedure TForm1.LoadData;


const
AFileName = 'balance sheet. TXT';
AHeaderLineCount =;

var
ARecords, AValues: TStringList;
I: Integer;

to procedure InitRecord (const Str: string);


var
J: Integer;
V: Variant;
begin
AValues.CommaText: = Str;
for J: = 0 to AValues.Count - 1 do
the if AValues.Strings [J] <> '-' THEN
begin
V: = AValues.Strings [J];
the IF NOT VarIsNull (V) then
cxGrid1TableView2.DataController.Values ??[i, j]: = V;
end;
end;

begin
if not FileExists (AFileName) then
raise Exception.Create ('Data file not found');

ARecords: = TStringList.Create;
AValues: = TStringList.Create;

with ARecords do
try
LoadFromFile (AFileName);
cxGrid1TableView2.BeginUpdate;
cxGrid1TableView2.DataController.RecordCount: = Count - AHeaderLineCount;
for I: = 0 to Count - (AHeaderLineCount + 1) do
InitRecord (Strings [I + AHeaderLineCount]);
finally
cxGrid1TableView2.EndUpdate;
ARecords.Free;
AValues.Free;
end;
end;

to procedure TForm1.FormCreate (Sender: TObject);


begin
CustomizeColumns;
LoadData_Zcfz;
end;

13) How to change the color of the column?


var
AFirstColumnStyle: TcxStyle;
to procedure TForm1.FormCreate (Sender: TObject);
begin
/ / Column color
AFirstColumnStyle: = TcxStyle.Create (Self);
AFirstColumnStyle.Color: = clAqua;
AFirstColumnStyle.TextColor: = clBlue;
cxGrid1TableView1.Columns [1]. Styles.Content: = AFirstColumnStyle;
end;

14) Set as default the usage?


The resolve: Set as the default usage is done in order to solve the convenience of setting parameters, such as:
Even good database, change cxGrid1DBBandedTableView1-> OptionsCustomize-> ColumnFiltering set to False. (This setting can
OK, next time you generate a new cxGrid1DBBandedTableView1 these settings and just the same. If you need to set the param

15) How to make the mouse to move the text color in the corresponding unit?
Solution:
var
FTrackItem: TcxCustomGridTableItem;
FTrackRec: TcxCustomGridRecord;

The procedure TForm1.cxGrid1DBTableView1CustomDrawCell (


Sender: TcxCustomGridTableView; ACanvas: TcxCanvas;
AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
begin
if (AViewInfo.GridRecord = FTrackRec) and (AViewInfo.Item = FTrackItem) then
begin
ACanvas.Font.Color: = clred; / / red font
ACanvas.Font.Style: = [fsUnderline] ;/ / underlined
end;
end;

procedure TForm1.cxGrid1DBTableView1MouseMove (Sender: TObject;


The Shift: TShiftState; X, Y: Integer);
var
AHitTest: TcxCustomGridHitTest;
ATrackItem: TcxCustomGridTableItem;
ATrackRec: TcxCustomGridRecord;
begin
ATrackItem: = FTrackItem;
ATrackRec: = FTrackRec;

AHitTest: = (Sender as TcxGridSite). GridView.ViewInfo.GetHitTest (X, Y);


if AHitTest is TcxGridRecordCellHitTest then
begin
FTrackItem: = TcxGridRecordCellHitTest (AHitTest). Item;
FTrackRec: = TcxGridRecordCellHitTest (AHitTest). GridRecord;
end
else
begin
FTrackItem: = nil;
FTrackRec: = nil;
end;

if (ATrackItem <> FTrackItem) or (ATrackRec <> FTrackRec) then


begin
/ / Invalidate old cell
if ATrackRec <> nil then
ATrackRec.Invalidate (ATrackItem);
/ / Invalidate new cell
if FTrackRec <> nil then
FTrackRec.Invalidate (FTrackItem);
end;
end;

16) in cxgrid in dxdbgrid ExpressQuantumGrid 3.2.2 and 4.2 versions What is the difference?
There is a big difference, basically the equivalent of two controls.
The, so cxgrid does not support dxdbgrid cxgrid is a complete rewrite of the in dxdbgrid based on
So cxgrid which specifically provides a will dxdbgrid to import to cxgrid function.

17) how to design multiple headers cxGrid?


Solution: cxGrid header can be solved as follows:
---------------------------------
|1|2|
---------------------------------
| Field | Field | Field | Field |
| The fields 5 | field 6 |
| Field | field | Field 9 |
Achieve this is very simple, you can directly drag the field names in the above is displayed, drag the arrows into the location wh

But cxGrid can not be achieved as follows multi-table form:


---------------------------------
|1|2|
---------------------------------
|3|4|5|6|
| Field 1 | field 2 |
| Field | Field | field 5 |
I do not know who can achieve such a multi-table?

18) from the table structure, the main point to open the "+" how the focus on the corresponding master table records?
Solution:
var
HitTest: TcxCustomGridHitTest;

procedure TColumnsShareDemoMainForm.tvProjectsMouseDown (Sender: TObject;


Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
/ / Note that the Sender parameter is a Site
HitTest: = (sender as TcxGridSite), GridView.ViewInfo.GetHitTest (X, Y);
/ / The point belongs to the [+] / [-] button area
if HitTest is TcxGridExpandButtonHitTest then
/ / Move focus to the record
TcxGridExpandButtonHitTest (HitTest). GridRecord.Focused: = True;
end;

At 19) CXGrid4 Expand all nodes


Solve: GridDBTableView1.DataController.Groups.FullExpand;

2003-12-12 17:07:30 problem of 20


20) cxGrid the how to dynamically create items Items Editor?
The column of cxGrid have a property, the edit box you can specify the ComboBox, spinedit. At design time, you can
The combobox items add an item will be dynamically created? (run-time added by the program)

Solution:
var
A: TDataSource:
B: TcxlookupcomboboxProperties;
begin
A: = TDataSource.create (self);
B: = tcxlookupcomboboxproperties.create to (self);
A.Dataset: = Dic_ry_xb ;/ / here the specified data source.
b.listdource: = A ;/ / here the specified field listsource property.
b.keyfieldnames: = 'a'; / / here the key fields of the specified field
b.listfieldnames: = 'b'; / / specified herein the return value of the field.
b.listcolumns.items [0]. caption: = 'x; / / default here is to build a field, but the header is the name, so here it noon want.
cxGrid1DBTableView1c1_sex_code.Properties: = b; / / specified herein that field.
end; / / This is the initialization code,
2004-1-7 14:05:14 Question 21
21) ExpressQuantumGrid4.5 finished package where you can download ExpressQuantumGrid4.5 the finished package, coverin
et the need to sum a column, add Add summary.default for Groups total field fieldname column under Display Statistics field, the format fo

p to people just getting started with cxGrid.

which is equivalent to a collection of PageControl

xGrid1 can add a cxGrid1Level2 right-click

e sub-Level, Create View

DBGrid mouse button can be used, you can count

nt of personnel files;

bleName Set biolife.db,

1 DataController,

ick cxGrid1DBTableView1 selection

to BlobEdit; look at the operation

erties Stretch is set to True,


r, etc., slowly pondering it :)

e changed to Chinese?
ustomDrawGroupCell:

etting the table from the Table or Query mastersource

appropriate settings cxGrid1Level1, and cxGrid1Level2 Caption value.


er.Values ??[1, 1];
milar functionality.

ow will show, that can drag a field to put

ove there will be a small triangle up or down, this

field rise or fall sort.


TableView will be the last remains of parameters. This has not been tested.
meters, such as:
ring set to False. (This setting can be to the drop-down list of field names removed) change cxGrid1DBBandedTableView1-> OptionsView->
me. If you need to set the parameters of a lot of the time, the Set as default useful!
g the arrows into the location where you want to display on the OK. Or Edit Layout in the right click cxGrid1DBBandedTableView1 menu can

ng master table records?


design time, you can

ame, so here it noon want.

.5 the finished package, covering the files directly to the source file on it.
lay Statistics field, the format for format, kind of statistical methods, position for the seat spfooter below the packet, spgroup in the top of
dedTableView1-> OptionsView-> Navigator set for True. Then right-click cxGrid1DBBandedTableView1, inside the pop-up menu bar, click Se
DBBandedTableView1 menu can also drag and drop.
he packet, spgroup in the top of the packet or with cxGridPopupMenu1, at run-time for any type of digital sum a column, simply set cxGrid
de the pop-up menu bar, click Set as default.
sum a column, simply set cxGridPopupMenu1 property Grid for cxGrid1DBTableView1 cxGrid
I would do something like this

First Clear the bands in your grid

for I := 0 to YourGrid.bands.count-1
YourGrid.bands[I].Free;

You then create the header bands

CreateBands('Prime key Header',YourGrid);


CreateBands('Main Title 1 Header',YourGrid);
CreateBands('Main Title 2 Header',YourGrid);

You then hook up your columns to the Bands index

for I := 0 to YourGrid.ColumnCount - 1 do
begin
if (YourGrid.Columns[I].Caption = 'prim_key') then
YourGrid.Columns[I].Position.BandIndex := 0

end;

pop up edit!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Dibawah ini

To obtain properties of the current PopupEdit editor that are currently in effect, use the ActiveProperties property:

[Delphi]Open in popup window


TcxPopupEdit(Sender).ActiveProperties.PopupControl := nil;
Properties property:
pop up edit!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Dibawah ini

To obtain properties of the current PopupEdit editor that are currently in effect, use the ActiveProperties property:

[Delphi]Open in popup window


TcxPopupEdit(Sender).ActiveProperties.PopupControl := nil;

Close dropdown of Popupedit when text is empty

Tags:

Hi,

Can you please look at the attached demo, it is the same demo of last weeks question.
As you can see i perform a

[Delphi]
TcxPopupEditProperties(edt_zoekpatient.Properties).PopupControl.Visible := False;

on curchange of the component, but that doesn't do the trick, the popupcontainer is still showing when the edititem text is em

I want the popupwindow to be hidden when the text is empty.

thanks!

Leave a Comment

1Solution

Paulo (DevExpress Support) 3 years ago

Hello Franky,

I think that it is much more convenient to use the edt_zoekpatient.Properties.OnChange event or similar events of the Properti

[Delphi]Open in popup window


procedure TForm1.edt_zoekpatientPropertiesChange(Sender: TObject);
begin
if Length(TcxPopupEdit(Sender).EditingText) > 0 then
begin
grd_patientDBTableView1.Datacontroller.Filter.Active := False;
grd_patientDBTableView1.Datacontroller.Filter.Root.Clear;
grd_patientDBTableView1.Datacontroller.Filter.Root.AddItem(grd_patientDBTableView1Col1, foLike,
'%' + edt_zoekpatient.CurEditValue + '%',edt_zoekpatient.CurEditValue);
edt_zoekpatient.EditValue := edt_zoekpatient.CurEditValue;
grd_patientDBTableView1.Datacontroller.Filter.Active := True;
end
else
TcxPopupEdit(Sender).DroppedDown := False;
end;
Properties property:

ing when the edititem text is empty.

or similar events of the Properties collection. The benefit is that in this event you have the Sender parameter that is an in-place editor cre
iew1Col1, foLike,
ter that is an in-place editor created based on the Properties class you are using. For example, for the TcxPopupEditProperties properties c
opupEditProperties properties class an in-place TcxPopupEdit editor is created. This means that you can use the DroppedDown property to
e the DroppedDown property to control your editor's DropDown window:
Howtosetupanunbounditeminadata-awareView

The new ExpressQuantumGrid 5 supports this functionality and allows you to set such an unbound column (row - for a Card Vi

Here are the necessary steps (the code snippets will illustrate how to perform the same operations programmatically):
1. IMPORTANT. This feature requires the Data Controller to be in the following settings:
- default data loading mode - make sure to set the Data Controller's DataModeController.GridMode property to False

[Delphi]Open in popup window


<aView>.DataController.DataModeController.GridMode := False;

- Smart Refresh mode - set the Data Controller's DataModeController.SmartRefresh property to True

[Delphi]Open in popup window


<aView>.DataController.DataModeController.SmartRefresh := True;

- key field(s) - you must initialize the Data Controller's KeyFieldNames property

[Delphi]Open in popup window


<aView>.DataController.KeyFieldNames := 'aUniqueField';

2. Add a new column to a View. Do not initialize its DataBinding.FieldName property.

[Delphi]Open in popup window


var

aCol: TcxGridDBColumn;

...

aCol := <aView>.CreateColumn;

with aCol do

begin

Name := 'colUnbound';

Caption := 'Check';

end;

3. Set the column's DataBinding.ValueType to an appropriate value. This property specifies the string representation of the dat
[Delphi]Open in popup window
uses

cxDataStorage;

...

aCol.DataBinding.ValueTypeClass := TcxBooleanValueType;

NOTE: When setting the value type programmatically, you should refer to the DataBinding.ValueTypeClass property instead an
4. Bind an appropriate editor to the column. Set the column's Properties property to the necessary value (CheckBox in our inst

[Delphi]Open in popup window


uses

cxCheckBox;

...

aCol.PropertiesClass := TcxCheckBoxProperties;

//OR

aCol.PropertiesClassName := 'TcxCheckBoxProperties';

NOTE: When setting the Properties property value programmatically, you should refer to the item's PropertiesClass or Properti
5. Adjust the column Properties' settings as your need dictate. For example, set the ValueChecked and ValueUnchecked prope

[Delphi]Open in popup window


with aCol.Properties as TcxCheckBoxProperties do

begin

AllowGrayed := False;

ValueChecked := True;

ValueUnchecked := False;

end;
ound column (row - for a Card View).

tions programmatically):

Mode property to False

e string representation of the data type which the data binding provides. For example, if you wish the column to store logical values, set the
ueTypeClass property instead and use the corresponding value type class.
ssary value (CheckBox in our instance).

em's PropertiesClass or PropertiesClassName property instead and use the corresponding properties type class.
ked and ValueUnchecked properties to the values used in your application:
mn to store logical values, set the DataBinding.ValueType property to Boolean.
Showing cell content on hint in DevExpress grid

I am using TcxGridDBTableView from DevExpress. Some of the cells contain really long strings, so I want to be able to show the

Do you know how to simply achieve this?

+2 A:

Try this

procedure TForm1.cxGrid1TableView1Column3GetCellHint(
Sender: TcxCustomGridTableItem; ARecord: TcxCustomGridRecord;
ACellViewInfo: TcxGridTableDataCellViewInfo; const AMousePos: TPoint;
var AHintText: TCaption; var AIsHintMultiLine: Boolean;
var AHintTextRect: TRect);
begin
AHintText := VarToStr(ARecord.Values[Sender.Index]);
AIsHintMultiLine := True;
end;

http://www.devexpress.com/Support/Center/p/B133087.aspx

RRUZ 2009-08-14 17:01:46


so I want to be able to show them to users using Hints. I want also to be able to do have line brakes in hint in places of semicolon in my tex
in places of semicolon in my text.

Das könnte Ihnen auch gefallen