Summary of Cxgrid's checkbox

Source: Internet
Author: User

Adding selection columns to Cxgrid

1, in the dataset (Query/table/clientdataset etc) Fieldeditor increase the calculated field Fdselect,datatype is a string, of course, other types can be. Fieldkind is set to fkcalculated or Fkinternalcalc; When set to Fkinternalcalc, it should be noted that the SELECT statement reads as follows: Select ' 0 ' as fdselect,* from TableA, Otherwise, the field "* * *" not found will be reported. When set to fkcalculated, you do not need to change the original statement.

Object Strngfldwaitinfdselect:tstringfield
Fieldkind = Fkinternalcalc
FieldName = ' Fdselect '
End

2, Cxgrid dbtableview Add Column Cxgrdbclmnselect, set the properties as a checkbox, the following settings:

Object Cxgrdbclmnselect:tcxgriddbcolumn
        Caption = #36873 #25321
        databinding.fieldname = ' fdselect '
         propertiesclassname = ' tcxcheckboxproperties '
        properties.displaygrayed = ' nssunchecked '
        properties.valuechecked = ' 1 '
        properties.valuegrayed = ' nssunchecked '
         properties.valueunchecked = ' 0 '
        MinWidth = 25
        options.editing = false //Important, many friends talked about, not responding to Cellclick events, Set to False to respond.
        options.filtering = False
         Options.incsearch = False
      end

3. Add code in Cellclick or MouseUp as needed

Var
Row:integer;
Begin
If CxgrdbtblvwGrid1DBTableView1.ViewData.RecordCount = 0 Then
Exit;
row: = CxgrdbtblvwGrid1DBTableView1.DataController.FocusedRowIndex;
If Cxgrdbtblvwgrid1dbtableview1.viewdata.records[row]. Values[0] = ' 1 ' Then
Cxgrdbtblvwgrid1dbtableview1.viewdata.records[row]. Values[0]: = ' 0 '
Else
Cxgrdbtblvwgrid1dbtableview1.viewdata.records[row]. Values[0]: = ' 1 ';
End

4, F9 look at the effect.

Ps:fkcalculated and Fkinternalcalc

Fields calculated by SQL servers or the Borland Database Engine to display the results of a query that returns a live data Set has a fieldkind of Fkinternalcalc, not fkcalculated. This was because the field values are stored in the dataset. Calculated fields in a client datasets that is calculated in an event handler but stored in the dataset also has a Fi Eldkind of Fkinternalcalc instead of fkcalculated. Unlike regular calculated, internally calculated fields can is used in filter expressions. They can is edited, but the changes is discarded. To prevent editing, set the property to True.

Summary of Cxgrid's checkbox

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.