如何关闭rowselect在DBGrid中整行排列? [英] how can i colour whole row in DBGrid with rowselect turned off?

查看:165
本文介绍了如何关闭rowselect在DBGrid中整行排列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

RowSelect会中断OnCellClick的功能,所以我需要关闭RowSelect。
那么如何通过突出显示当前行的所有单元格来模拟行选择?

RowSelect breaks the functionality of OnCellClick, so I need to turn RowSelect off. So then how can I simulate to look of row select by highlighting the all the cell of the current row?

推荐答案

使用 TDBGrid.OnDrawColumnCell 事件,并设置状态以指示已选择行。

Use the TDBGrid.OnDrawColumnCell event, and set the State to indicate the row is selected.

procedure TfrmPrimaryCare.dbGrdPCClaimsDrawColumnCell(Sender: TObject;
  const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState);
var
  NewState: TGridDrawState;
  RowSelected: Boolean;
begin
  NewState := State;
  RowSelected := (Sender as TDBGrid).SelectedRows.CurrentRowSelected;
  if (RowSelected) then
    NewState := NewState + [gdSelected];
  TDBGrid(Sender).DefaultDrawColumnCell(Rect, DataCol, Column, NewState);
end;

这篇关于如何关闭rowselect在DBGrid中整行排列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆