In DBGrid, click a cell to select an entire row, double-click and edit the cell

Source: Internet
Author: User

In the design process, sometimes a large amount of data, field more time, just click on the cell may be a field of data mistakenly operation (such as data wrong line), this will think of this problem, the solution is as follows: Click on the cell to change the current row color.

First DBGrid the property to do the next set (in fact, also dbgrid default properties)

Dbgrid1->options->dgediting=true
Dbgrid1->options->dgrowselect=false


First, before the implementation to do the following definition
Type
Tmydbgrid=class (TDBGrid);


Second, the Ondrawcolumncell operation in the DBGrid
Procedure Tfrm_hetong. Dbgrid2drawcolumncell (Sender:tobject;
Const Rect:trect; Datacol:integer; Column:tcolumn;
State:tgriddrawstate);
Begin
With Tmydbgrid (Sender) do
Begin
If Datalink.activerecord=row-1 Then
Begin
Canvas.font.color:=clwhite;
canvas.brush.color:=$00800040;
End
Else
Begin
Canvas.brush.color:=color;
Canvas.font.color:=font.color;
End
Defaultdrawcolumncell (rect,datacol,column,state);
End
End

In DBGrid, click a cell to select an entire row, double-click and edit the cell

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.