Cxgrid usage (take row, column value; Locate selected row, etc.)

Source: Internet
Author: User

Delphi Cxgrid Gets the selected column, collation, value in the cell currently being edited cxGrid1DBTableView1.Controller.FocusedRowIndex the current line number


4. Get Cxgrid Collation



CxGrid1DBTableView1.Controller.FocusedRow as a forward
CxGrid1DBTableView1.Controller.FocusedColumn Current Column
CxGrid1DBTableView1.Controller.FocusedColumnIndex Current column number
CxGrid1DBTableView1.Controller.EditingItem the cell box in the current edit
CxGrid1DBTableView1.Controller.EditingController.Edit The current edit box



You can take the value of the current cell in the edit state:
If CxGrid1DBTableView1.Controller.FocusedColumn.Editing Then

ShowMessage (CxGrid1DBTableView1.Controller.EditingController.Edit. Editingvalue)

Else
CxGrid1DBTableView1.DataController.GetValue (CxGrid1DBTableView1.DataController.FocusedRecordIndex,
CxGrid1DBTableView1.Controller.FocusedItemIndex);



The values in the cell can be obtained in a non-editable state:
Oncellclick Event code:
Procedure Tform1.cxgrid1dbtableview1cellclick (
Sender:tcxcustomgridtableview;
Acellviewinfo:tcxgridtabledatacellviewinfo; Abutton:tmousebutton;
Ashift:tshiftstate; var ahandled:boolean);
Var
V:variant;
Begin
V: = Acellviewinfo.value;
End






Fetch column Value
I: = CxGrid1DBBandedTableView1.Controller.FocusedColumn.Index;
CxGrid1DBBandedTableView1.DataController.GetValue (Cxgrid1dbbandedtableview1.controller.selectedrows[0]. Recordindex,i);
cxgrid1dbtableview1.datacontroller.values[row, column]
Gets the focus
Cxgrid1dbtableview1.columns[5]. Focuswithselection;
Cxgrid1dbtableview1.columns[4]. Focused:=true;
Get the value of the cell that is currently clicked
Uses   clipbrd;



Oncellclick Event code:
Procedure Tform1.cxgrid1dbtableview1cellclick (
Sender:tcxcustomgridtableview;
Acellviewinfo:tcxgridtabledatacellviewinfo; Abutton:tmousebutton;
Ashift:tshiftstate; var ahandled:boolean);
Var
V:variant;
Begin
V: = acellviewinfo.value;//value
Clipboard.astext: = Vartostr (v);//Save to Clipboard
End
The name of the Cxgrid Dbtableview is DGTV1



1. Return the selected number of rows GDTV1. Datacontroller.getselectedcount;





2. Returns the index of the selected row: GDTV1. Datacontroller.getselectedrowindex (0), which represents the index of the first selected row





3. Return the data of the selected row;



Var
I, J:integer;
Begin
For I:=0 to GDTV1. Datacontroller.getselectedcount-1 DO begin
J: = GDTV1. Datacontroller.getselectedrowindex (I);
ShowMessage (Vartostr (GDTV1. Datacontroller.getvalue (J, 0)); Select the value of the column in row
End
End





Const
Orderarray:array[sonone. Sodescending] of String = (' None ', ' ASC ', ' DESC ');
Var
I:integer;
S, orderstr:string;
Begin
For I: = 0 to GDTV1. SortedItemCount-1 DO begin
If S <> ' then
S: = s + ', ';
ORDERSTR: = Orderstr + GDTV1. Sorteditems[i]. Databinding.defaultcaption + ";
ORDERSTR: = Orderstr + Orderarray[tcxdatasortorder (GDTV1. Sorteditems[i]. SortOrder)];
S: = s + orderstr;
End
ShowMessage (' ORDER by ' + S);





5. Get the values for multiple selections



For I: = 0 to Cxgrid1. Selectedrows.count-1 do
Begin
Cxgrid1. DataSource.DataSet.GotoBookmark (Pointer (cxgrid1. Selectedrows.items[i])); Locate the selected field



End






6.//Select the value of the 1th column of the row


For i:=0 to Cxgrid1dbtableview1.datacontroller.getselectedcount-1 do
Begin
J: = CxGrid1DBTableView1.DataController.GetSelectedRowIndex (I);
ShowMessage (Vartostr (CxGrid1DBTableView1.DataController.GetValue (J, 0));



End





7. Get the value of the selected row



With Cxgrid1dbtableview1.controller do
Begin



For i:=0 to SelectedRowCount-1 do
Begin
Selectedrows[i]. Focused:=true;
ShowMessage (Adoquery1.fieldbyname (' MC '). asstring);
End



End



Cxgrid usage (take row, column value; Locate selected row, etc.)


Alibaba Cloud Hot Products

Elastic Compute Service (ECS) Dedicated Host (DDH) ApsaraDB RDS for MySQL (RDS) ApsaraDB for PolarDB(PolarDB) AnalyticDB for PostgreSQL (ADB for PG)
AnalyticDB for MySQL(ADB for MySQL) Data Transmission Service (DTS) Server Load Balancer (SLB) Global Accelerator (GA) Cloud Enterprise Network (CEN)
Object Storage Service (OSS) Content Delivery Network (CDN) Short Message Service (SMS) Container Service for Kubernetes (ACK) Data Lake Analytics (DLA)

ApsaraDB for Redis (Redis)

ApsaraDB for MongoDB (MongoDB) NAT Gateway VPN Gateway Cloud Firewall
Anti-DDoS Web Application Firewall (WAF) Log Service DataWorks MaxCompute
Elastic MapReduce (EMR) Elasticsearch

Alibaba Cloud Free Trail

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.