또 질문입니다...
염치없습니다...
이번건 좀 까다로운거 같은데...
아래소스는 간단히 질문 부분만 보여 드립니다...
DBGrid1에서...
edit모드 일때 마우스나 키보드로 행을 선택했을경우...
행이 반전(selected)되지 않습니다...
그래서 선택된 행을 반전 시키게 하기위해
아래와 같이 처리를 했습니다...
작동은 잘되는데...
그리드를 스크롤할때만은 그렇치 않더군요...
'▼' 누를 경우...
스크롤되면서 그부분 전체가 반전이 되더군요...
아무리 지지고 볶아봐도 되진 않네요...
어떻게 해야 될까요...
부탁드립니다...
설명이 이해가 가는지 모르겠네요...
================================================================
private
{ Private declarations }
CurrBjDate, CurrProID : String;
procedure DrawField(const Value : String;
const Rect : TRect;
vCanvas : TCanvas;
vFont: TFont;
vAlignment: TAlignment;
FontStyle : TFontStyles;
FontColor : TColor;
BGColor : TColor);
.
.
중간 생략...
.
.
procedure Tf411.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
if state <> [gdSelected] Then
with Sender as TDBGrid, DataSource.DataSet do
begin
if ((FieldByName('BjDate' ).AsString = CurrBjDate ) and
(FieldByName('ProID' ).AsString = CurrProID )) then
DrawField(Column.Field.DisplayText, Rect, Canvas, Column.Font, Column.Alignment, [], clWindow, clActiveCaption );
end;
end;
procedure Tf411.Query1AfterScroll(DataSet: TDataSet);
begin
CurrBjDate := DataSet.FieldByname('BjDate' ).AsString;
CurrProId := DataSet.FieldByname('ProID' ).AsString;
end;
procedure Tf411.DBGrid1KeyPress(Sender: TObject; var Key: Char);
begin
If (Key <> #13) AND (Key <> #9) Then
Begin
If (not (DBGrid1.SelectedIndex = 9)) Then
Begin
Abort;
Exit;
End
End;
If (Key = #13) then
SendMessage(TDBGrid(Sender).Handle, WM_KEYDOWN, VK_RIGHT,0);
Case DBGrid1.SelectedIndex of
0..8 : DBGrid1.SelectedIndex := 9;
9 : begin
If not Query1.EOF Then
SendMessage(TDBGrid(Sender).Handle, WM_KEYDOWN, VK_DOWN,0);
DBGrid1.SelectedIndex := 9;
end;
end;
end;
==================================================================================
|