procedure TChannelSelectForm.StringGrid_ChannelSetDrawCell(Sender: TObject; ACol,<br> ARow: Integer; Rect: TRect; State: TGridDrawState);<br>var<br> TmpGrid: TStringGrid;<br> TmpStr: string;<br> TmpChannelID: Integer;<br> TmpRect: TRect;<br>begin<br> TmpGrid := Sender as TStringGrid;<br> TmpChannelID := ARow + ACol * iCellCountPerCol; //通道号 0 - 255<br> TmpStr := Format('%.3d', [TmpChannelID + 1]); //显示字<br> if TmpChannelID in FChannelSet then<br> tmpGrid.Canvas.Brush.Color := clSkyBlue; //如果选中显示绿色<br> TmpRect.Left := Rect.Left + 1;<br> TmpRect.Right := Rect.Right - 1;<br> TmpRect.Top := Rect.Top + 1;<br> TmpRect.Bottom := Rect.Bottom - 1;<br> tmpGrid.Canvas.FillRect(TmpRect); <<----------<br><br> DrawText(tmpGrid.Canvas.Handle,<br> pChar(TmpStr),<br> Length(TmpStr),<br> Rect, // 包含文字的矩形<br> DT_CENTER or // 水平居中<br> DT_SINGLELINE or // 不折行<br> DT_VCENTER); // 垂直居中 <br>end;