Delphi cxgrid usage

Source: Internet
Author: User

 

Delphi cxgrid usage
1. Bind data
Method
Cxgrid1dbtableview1. datacontroller. datasource: = performance1
2. Remove "drag a column header here to group by that column"
Method
Cxgrid1dbtableview1. optionsview. Set groupbybox to false.
3. Remove the lower triangle data from the header.
Method
Cxgrid1dbtableview1. optionscustomize. columnfiltering is set to false
4. Add serial number
Method
Add the mycount field type to dataset as string
Add the display field number mycount in cxgrid.
Write event for this field
Procedure tfrm_form.redataset2mycountgettext (Sender: tfield;
VaR text: string; displaytext: Boolean );
Begin
Inherited;
Text: = inttostr (redataset2.recno );
End;

Bind the serial number to the field mycount

5. Add a column to the cxgrid to display the checkbox.
Method
Add the myselect field type as Boolean in dataset.

Add a display field in cxgrid and select

Set the properties of the select field to checkbox. readonly = false;
Nullstyle = nssunchecked

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;
// Single answer
// For row: = 0 to cxgrid1db tableview1. datacontroller. RecordCount-1 do
// Begin
// Cxgrid1dbtableview1. viewdata. Records [row]. Values [0]: = false;
// End;
// Select multiple
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 from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/fkedwgwy/archive/2009/08/19/4463732.aspx

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.