|
|
- - - - - - - - - - - - - - ผู้ให้การสนับสนุน- - - - - - - - - - - - - -
|
|
|
กระทู้ #955 [Delphi] (จาก IP: 203.155.172.27)
การload และsave file .txt ใน stringgrid ทำยังไงครับ
การload และsave file .txt ใน stringgrid ทำยังไงครับ และสอนวิธีสร้าง object memoระหว่างrun programหน่อยครับ
|
จากคุณ
:
um / jeanchern@hotmail.com [2007-02-27 22:40:56]
|
|
ความคิดเห็น #26147 (จาก IP: 203.146.63.184)
สมมุติว่า StringGrid ไม่มี FixedRow และ FixedColumn Save ข้อมูลดังนี้ ---------------------------------------- Var Tmp:TStringList; x,y : Integer; Begin Tmp := TStringList.Create; for y := 0 to StringGrid1.RowCount-1 do for x := 0 to StringGrid1.ColCount-1 do Tmp.Add(StringGrid1.Cell[x,y]); Tmp.SaveToFile('DataGrid.Txt'); Tmp.Free; End; -------------------------------------- Load ข้อมูล -------------------------------------- Var Tmp : TStringGrid; Max, x, y : Integer; S : String; Begin //ลบข้อมูลเดิม for y := 0 To StringGrid1.RowCount-1 do for x := 0 to StringGrid1.ColCount-1 do StringGrid1.Cell[x,y] := ''; Tmp := TStringList.Create; Tmp.LoadFromFile('DataGrid1.Txt'); Max := 0; y := 0; x := 0; While (Max < Tmp.Count) do Begin S := Tmp[Max]; StringGrid1.Cell[x,y] := S; if x = StringGrid1.ColCount-1 Then Begin x := 0; inc(y); End ELse inc(x); inc(max); End; Tmp.Free; End; |
จากคุณ
:
kruman [2007-10-12 22:18:12]
|
|
|
- - - - - - - - - - - - - - ผู้ให้การสนับสนุน- - - - - - - - - - - - - -
|
|
|
|
|