Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Delphi 使用RangeSelect的TStringGrid中的OnDrawCell调用不完整_Delphi - Fatal编程技术网

Delphi 使用RangeSelect的TStringGrid中的OnDrawCell调用不完整

Delphi 使用RangeSelect的TStringGrid中的OnDrawCell调用不完整,delphi,Delphi,我有一个启用了goRangeSelect的StringGrid和我自己的OnDrawCell过程。 但是当我开始使用shift和down键选择多行时,我遇到了一个问题,即只对行的第一列调用OnDrawCell,而我的选择是在按下任何键之前进行的 问题是我在需要移除的聚焦单元格周围绘制了一个矩形,因此我需要为旧行的每一列绘制一个OnDrawCell 是否有可能为每列获取OnDrawCell事件,或者我是否可以以其他方式解决此问题 下面是一些示例来演示这种行为。我使用Delphi7: 我将一个TMe

我有一个启用了
goRangeSelect
的StringGrid和我自己的
OnDrawCell
过程。 但是当我开始使用shift和down键选择多行时,我遇到了一个问题,即只对行的第一列调用
OnDrawCell
,而我的选择是在按下任何键之前进行的

问题是我在需要移除的聚焦单元格周围绘制了一个矩形,因此我需要为旧行的每一列绘制一个
OnDrawCell

是否有可能为每列获取
OnDrawCell
事件,或者我是否可以以其他方式解决此问题

下面是一些示例来演示这种行为。我使用Delphi7:

我将一个TMemo和一个TStringGird放在一个空表单上。在TStringGrid中,我使用以下代码激活goRowSelect和OnDrawCell的事件处理程序:

procedure TForm1.fGridDrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
   memo1.lines.add(format('Row: %d, Col: %d',[Arow,Acol]));
end;
现在我选择第一行并按下shift+cursor向下键。第一个光标按下后,我进入备忘录:

Row: 1, Col: 1   <---- Only the first col of row 1 is painted. Instead of all cols
Row: 2, Col: 1
Row: 2, Col: 2
Row: 2, Col: 3
Row: 2, Col: 4
Row: 2, Col: 1

Row:1,Col:1
OnDrawCell
如果为每个
单元格
触发,您可能会显示用于绘制和选择的代码。我添加了一个示例,希望现在更清楚。您是对的,这看起来像是在决定何时重新绘制单元格时出现的内部错误。使用
goRowSelect
不处理先前绘制的focusrect片段。解决方法可能是调用类似于
TStringGrid(发送方)。无效工作。我发现使选择的第一行和最后一行无效已经足够了:
Grid.InvalidateRow(Grid.selection.Bottom);Grid.InvalidateRow(Grid.Selection.Top)