정말정말 죄성합니다...ㅜㅜ
혼자 해볼려고 도움말 띄워서 열심히 찾아봤는데 당췌 모르겠다는...
Windows.DrawText(Handle, PChar(Column.Field.AsString), Length(Column.Field.AsString), R, DT_CENTER);
여기서 R이 뭔가요??
도움말에 보니
Points to a RECT structure that contains the rectangle (in logical coordinates) in which the text is to be formatted.
라고 써있던데 무슨 의미인줄 모르겠네요...
한번만 더 부탁드립니다...
바쁜데 죄송합니다...^^;;
civilian,안영제 님이 쓰신 글 :
: 이승근 님이 쓰신 글 :
: : 감솨감솨...^^;;
: : 역시 안영제님 덕에 제가 삽니다요...ㅋㅋㅋ
: : 그런데 정렬은 어떻게 적용합니까??
: : 가운데 정렬을 해야하는디요...
: : 글고 시간나면 카페에 한번 들려주세요...^^
: :
: : civilian,안영제 님이 쓰신 글 :
: : : TDBGrid의 OnDrawColumnCell 이벤트에서 다음과 같이 코드를 붙이면 됩니다.
: : :
: : : procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
: : : DataCol: Integer; Column: TColumn; State: TGridDrawState);
: : : begin
: : : if Column.Index = 1 then
: : : with DBGrid1.Canvas do
: : : begin
: : : Brush.Color := clBlue;
: : : FillRect(Rect);
: : : TextOut(Rect.Left, Rect.Top, Column.Field.Value);
: : : end;
: : : end;
:
: 가운데 정렬을 해야한다면 TextOut 대신에
:
: Windows.DrawText(Handle, PChar(Column.Field.AsString), Length(Column.Field.AsString), R, DT_CENTER);
:
: 함수를 쓰세요.
: : :
: : :
: : : 이승근 님이 쓰신 글 :
: : : : procedure Twonjang6F.DrawField(const Value : String; const Rect : TRect;
: : : : vCanvas : TCanvas; vFont: TFont; vAlignment: TAlignment;
: : : : FontStyle : TFontStyles; FontColor : TColor; BGColor : TColor);
: : : : var I : Integer;
: : : : begin
: : : : I := 0;
: : : : vCanvas.FillRect(Rect);
: : : : SetBkMode(Canvas.Handle, TRANSPARENT);
: : : : vCanvas.Font := vFont;
: : : : vCanvas.Font.Style := FontStyle;
: : : : vCanvas.Font.Color := FontColor;
: : : : vCanvas.brush.Color := BGColor;
: : : : case vAlignment of
: : : : taRightJustify :
: : : : begin
: : : : SetTextAlign(vCanvas.Handle, TA_RIGHT);
: : : : I := Rect.Right - 2;
: : : : end;
: : : :
: : : : taLeftJustify :
: : : : begin
: : : : SetTextAlign(vCanvas.Handle, TA_LEFT);
: : : : I := Rect.Left + 2;
: : : : end;
: : : :
: : : : taCenter :
: : : : begin
: : : : SetTextAlign(vCanvas.Handle, TA_CENTER);
: : : : I := (Rect.Right + Rect.Left) DIV 2;
: : : : end;
: : : : end;
: : : : vCanvas.TextRect(Rect, I, Rect.Top + 2, Value);
: : : : SetTextAlign(vCanvas.Handle, TA_LEFT);
: : : : end;
: : : :
: : : : procedure Twonjang6F.DBGrid1DrawColumnCell(Sender: TObject;
: : : : const Rect: TRect; DataCol: Integer; Column: TColumn;
: : : : State: TGridDrawState);
: : : : begin
: : : : with Sender as TDBGrid, DataSource.DataSet do
: : : : if FieldByName('gub1').AsString = '@' then
: : : : DrawField(Column.Field.DisplayText, Rect, Canvas, Column.Font, Column.Alignment, [], clBlue, clWindow);
: : : : end;
: : : :
: : : : 보통 위의 형식으로 행의 색은 바꾸었는데 특정열 즉, 특정 필드의 글자들만 색상을 바꾸고 싶습니다...
: : : : 예를 들어 a1, a2, a3, a4... 등의 필드가 있고 이것이 모두 DBGrid에 표시가 된다면 이중 a2필드의 글자들만 window바탕에 파란색으로 표시하고 싶습니다... 나머지는 물론 자연 그대로 표시하구요...
: : : : 어떻게 할까요??
|