if POS(cTab, sString) > 0 then
begin
sData := Copy(sString, 1, POS(cTab,sString) - 1);
sString := Copy(sString, POS(cTab,sString) + 1, Length(sString));
sData2 := Copy(sString, 1, POS(cTab,sString) - 1);
sString := Copy(sString, POS(cTab,sString) + 1, Length(sString));
sData3 := Copy(sString, 1, POS(cTab,sString) - 1);
sData4 := Copy(sString, POS(cTab,sString) + 1, Length(sString));
end
else
begin
if Length(sString) > 0 then
sData := sString
else
sData := '';
end;
with IttStringGrid1 do
begin
vv_Row := RowCount;
if Trim(Cells[0, vv_Row]) = '' then
begin
vv_Row := vv_Row - 1
end
else
begin
vv_Row := vv_Row + 1
end;
비슷한 소스가 있으니깐 수정해서 사용하면 될것같네요...
procedure TForm1.BitBtn3Click(Sender: TObject);
const
cTab = #9;
procedure SetDataToTable(pString : string);
var
sData : String;
sData2 : String;
sData3 : String;
sData4 : String;
sString : String;
vv_Row : LongInt;
begin
sString := pString;
if POS(cTab, sString) > 0 then
begin
sData := Copy(sString, 1, POS(cTab,sString) - 1);
sString := Copy(sString, POS(cTab,sString) + 1, Length(sString));
sData2 := Copy(sString, 1, POS(cTab,sString) - 1);
sString := Copy(sString, POS(cTab,sString) + 1, Length(sString));
sData3 := Copy(sString, 1, POS(cTab,sString) - 1);
sData4 := Copy(sString, POS(cTab,sString) + 1, Length(sString));
end
else
begin
if Length(sString) > 0 then
sData := sString
else
sData := '';
end;
with IttStringGrid1 do
begin
vv_Row := RowCount;
if Trim(Cells[0, vv_Row]) = '' then
begin
vv_Row := vv_Row - 1
end
else
begin
vv_Row := vv_Row + 1
end;
cells[0, vv_Row] := sData;
cells[1, vv_Row] := SData2;
cells[2, vv_Row] := SData3;
cells[3, vv_Row] := SData4;
RowCount := vv_Row;
end;
end;
var
F : Textfile;
sString : string;
begin
Label1.Caption := '';
Label2.Caption := '';
OpenDialog2.Execute ;
IttStringGrid1.RowCount := 2;
IttStringGrid1.ColRowClear;
if OpenDialog2.FileName <> '' then
begin
Screen.Cursor := crHourGlass;
AssignFile(F, OpenDialog2.FileName);
Reset(F);
try
try
while Not EOF(F) do
begin
Readln(F, sString);
SetDataToTable(sString);
end;
except
raise;
end;
finally
CloseFile(F);
IttStringGrid1.RowCount := IttStringGrid1.RowCount + 1;
IttStringGrid1.FixedRows := 1;
Screen.Cursor := crDefault;
end;
end;
end;