Delphi Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
델파이 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
FreePascal/Lazarus
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
델마당
볼랜드포럼 광고 모집

델파이 Q&A
Delphi Programming Q&A
[11483] StringGrid에 값을 표출하려하는데...값이 보여지지를 않습니다.
Ol츠미 [] 1565 읽음    2007-09-06 09:28
시리얼통신을 통해 데이터를 받아온 후에 그 값을

스트링그리드에 뿌려주려하는데...

값이 나타나지 않는건지...아니면 나타났다 바로 사라지는 건지...

화면에 값이 보여지지를 않습니다.

혹시 그리드 ROW수가 16인데 12까지만 먼저 넣고 후에 나머지 4개를 넣는 식으로 하면

값이 나타나지 않을 수도 있나요??

그리드에 값을 뿌려주는 부분의 소스는 다음과 같습니다.

FOR문으로 넣었다가 안되서..혹시나해서 일일이 값을 대입해줬습니다...ㅠㅠ

도움 부탁드립니다.


=============================================================================
procedure Tform_main.DLComportRxChar(Sender: TObject; Count: Integer);
var
data : String;
begin
DLcomport.ReadStr(data,Count);
  DLdataSet := DLdataSet + data;

  if (data[count-1] = #$0d) and (data[count] = #$0a) then begin
    memo1.Lines.Add('여기들어옴');
    DivideData_DL(saveTime, DLdataSet);
  end;
end;

procedure Tform_Main.DivideData_DL(cTime: TDateTime; str: String);
var
  DLdata : TStringList;
  DLvalue : Array of Double;
  i : Integer;
begin
DLdata := TStringList.Create;
  DLdata.DelimitedText := str;

  SetLength(DLvalue, DLdata.count);

  for i := 0 to DLdata.Count do begin
    DLRealData[i] := DLdata[i];
    DLvalue[i] := strToFloat(DLdata[i]) * gScale + goffset;
  end;

  with StringGrid1 do begin
    StringGrid1.Cells[1,1] := FormatFloat('0.00', DLvalue[12]);
    StringGrid1.Cells[1,2] := FormatFloat('0.00', DLvalue[13]);
    StringGrid1.Cells[1,3] := FormatFloat('0.00', DLvalue[14]);
    StringGrid1.Cells[1,4] := FormatFloat('0.00', DLvalue[15]);
    StringGrid1.Cells[1,5] := FormatFloat('0.00', DLvalue[16]);
    StringGrid1.Cells[1,6] := FormatFloat('0.00', DLvalue[17]);
    StringGrid1.Cells[1,7] := FormatFloat('0.00', DLvalue[18]);
    StringGrid1.Cells[1,8] := FormatFloat('0.00', DLvalue[19]);
    StringGrid1.Cells[1,9] := FormatFloat('0.00', DLvalue[20]);
    StringGrid1.Cells[1,10] := FormatFloat('0.00', DLvalue[21]);
    StringGrid1.Cells[1,11] := FormatFloat('0.00', DLvalue[23]);
    StringGrid1.Cells[1,12] := FormatFloat('0.00', DLvalue[25]);
  end;
  with StringGrid2 do begin
    StringGrid2.Cells[1,1] := FormatFloat('0.00', DLvalue[0]);
    StringGrid2.Cells[1,2] := FormatFloat('0.00', DLvalue[1]);
    StringGrid2.Cells[1,3] := FormatFloat('0.00', DLvalue[2]);
    StringGrid2.Cells[1,4] := FormatFloat('0.00', DLvalue[3]);
    StringGrid2.Cells[1,5] := FormatFloat('0.00', DLvalue[4]);
    StringGrid2.Cells[1,6] := FormatFloat('0.00', DLvalue[5]);
    StringGrid2.Cells[1,7] := FormatFloat('0.00', DLvalue[6]);
    StringGrid2.Cells[1,8] := FormatFloat('0.00', DLvalue[7]);
    StringGrid2.Cells[1,9] := FormatFloat('0.00', DLvalue[8]);
    StringGrid2.Cells[1,10] := FormatFloat('0.00', DLvalue[9]);
    StringGrid2.Cells[1,11] := FormatFloat('0.00', DLvalue[10]);
    StringGrid2.Cells[1,12] := FormatFloat('0.00', DLvalue[11]);
    StringGrid2.Cells[1,13] := FormatFloat('0.00', DLvalue[22]);
    StringGrid2.Cells[1,14] := FormatFloat('0.00', DLvalue[24]);
  end;

   DLdata.free;

end;

procedure Tform_main.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState);
var
  oldalign : word;
begin
   oldalign:=settextalign(StringGrid1.canvas.handle,ta_right);
   StringGrid1.canvas.textrect(rect,rect.right-2,rect.top+2, StringGrid1.cells[ACol,ARow]);
   settextalign(StringGrid1.canvas.handle,oldalign);
   GridDrawCeller(StringGrid1,ACol,ARow,Rect,State);
end;

procedure Tform_main.StringGrid2DrawCell(Sender: TObject; ACol,
ARow: Integer; Rect: TRect; State: TGridDrawState);
var
oldalign : word;
begin
   oldalign:=settextalign(StringGrid2.canvas.handle,ta_right);
   StringGrid2.canvas.textrect(rect,rect.right-2,rect.top+2, StringGrid2.cells[ACol,ARow]);
   settextalign(StringGrid2.canvas.handle,oldalign);
   GridDrawCeller(StringGrid2,ACol,ARow,Rect,State);
end;

procedure Tform_main.GridDrawCeller(Sender: TStringGrid; ACol, ARow: Integer;  Rect: TRect; State: TGridDrawState);
begin
  if ACol = 0 then begin
    Sender.Canvas.FillRect(Rect);
    Sender.Canvas.TextOut( ( Rect.Right - Sender.Canvas.TextWidth(Sender.Cells[ACol,ARow])) - 5, Rect.Top + 4, Sender.Cells[ACol,ARow]);
  end;
end;
==============================================================================

+ -

관련 글 리스트
11483 StringGrid에 값을 표출하려하는데...값이 보여지지를 않습니다. Ol츠미 1565 2007/09/06
11488     Re:StringGrid에 값을 표출하려하는데...값이 보여지지를 않습니다. 박지훈.임프 2268 2007/09/11
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.