Ehlib's Line checkbox

Source: Internet
Author: User

Set it up first.

Dbgrideh Property settings:

Indicatoroptions =

[Gioshowrowindicatoreh,//small triangular indication

Gioshowrecnoeh,//Data source line number

Gioshowrowselcheckboxeseh]//Show checkbox

Options = [..., dgmultiselect]//Turn on multiple selection to edit a checkbox

The above setup is complete, the function is there, for the selected row to traverse read

12345 forI := 0toDBGrideh.SelectedRows.Count - 1dobegin  DBGrideh.DataSource.DataSet.Bookmark := DBGrideh.SelectedRows[I];    //定位 ……    //读取定位后数据源其他操作end;

On the basis of the above to do a full select function upgrade.

The default Dbgrideh setting has the following settings

Allowedselections = [Gstrecordbookmarks,gstrectangle,gstcolumns,gstall]

At this point, the mouse click on the upper left corner of the Dbgrideh Indicatortitle can trigger the full selection of events, but unable to use the full selection of data records, find the next Dbgrideh.pas, found a key code

12345678910111213141516171819 procedureTCustomDBGridEh.DefaultIndicatorTitleMouseDown(Cell: TGridCoord;  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);var  DropdownMenu: TPopupMenu;  P: TPoint;  ARect: TRect;begin    ......endelseif (dgMultiSelect inOptions) and    DataLink.Active and([gstRecordBookmarks, gstAll] * AllowedSelections <> []) then  begin    if Selection.SelectionType <> gstNon then      Selection.Clear    elseifgstAll inAllowedSelections then      Selection.SelectAll    elseifgstRecordBookmarks inAllowedSelections then      Selection.Rows.SelectAll;  end;end;

The Dbgrideh is positioned by bookmarks the data source cursor row, where the default setting Allowedselections [Gstall,gstrecordbookmarks], when the Indicatortitle mouse click event is triggered, Found that the last piece of code run is to check Gstall first, and then check Gstrecordbookmarks, so although the selection, but unable to locate the data source cursor, so long as the allowedselections in the removal of [Gstall] can

No fields in the dataset are required.

However, this checkbox is easy to disappear, as long as the other rows of the grid can be clicked.

PassOptionsEh = [..., dghClearSelection, ...]  //dghClearSelection去掉

Method 2

There is a Boolean field in the DataSet, and a checkbox is automatically displayed.

Ehlib's Line 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.