Mam takie coś w listbox:
aaaaaa # bbb # cccc
aaaaaaa # bbbb # ccccc
aaaaaaaa # bbb # cccccc
aaaaaaaaa # bbbb #
# bbbb #
# bbb #
i chce teraz dokonać przeniesienia w dól to co jest krótsze od środkowej kolumny.
# bbb #
# bbbb#
aaaaaa # bbb #
aaaaaaa # bbbb # cccc
aaaaaaaa # bbbb # ccccc
aaaaaaaaa # bbb # cccccc
mam coś takiego :
var
i, x : integer;
sl, sl1, sl2, sl3, sl4 : TStringList;
sl_1, sl_2, sl_3 : TStringList;
begin
sl := TstringList.Create;
sl1 := TstringList.Create;
sl2 := TstringList.Create;
sl3 := TstringList.Create;
sl4 := TstringList.Create;
sl_1 := TStringList.Create;
sl_2 := TStringList.Create;
sl_3 := TStringList.Create;
sl.Text := ListBox1.Items.Text;
for i := 0 to sl.Count -1 do
sl4.Add(inttostr(length(sl[i])));
sl4.Sorted := True;
for i := 0 to sl.Count -1 do
sl[i] := sl[i] + StringOfChar(' ',strtoint(copy(sl4[sl4.Count-1],0,100))+1-Length(sl[i]))+'#';
ListBox1.Items.Text := sl.Text;
sl4.Clear;
for i := 0 to sl.Count -1 do
begin
sl1.Clear;
if pos('#', sl[i]) > 0 then
begin
ExtractStrings(['#','#'], [], PChar(sl[i]),sl1);
sl_1.Add(sl1[0]);
sl_2.Add(sl1[1]);
sl_3.Add(sl1[2]);
end;
end;
//----------------------------------------------------------------------------
x := 0;
for i := sl_1.Count-1 downto 0 do
begin
if copy(sl_1[i],0,1) = ' ' then inc(x);
if copy(sl_1[i],0,1) = ' ' then sl_1.Delete(i);
end;
for i := 1 to x do sl2.add('');
ListBox2.Items.Text := sl2.Text + sl_1.Text;
for i := 0 to ListBox2.Items.Count -1 do
sl4.Add(inttostr(length(ListBox2.Items[i])));
sl4.Sorted := True;
for i := 0 to ListBox2.Items.Count -1 do
ListBox2.Items[i] := ListBox2.Items[i] + StringOfChar(' ',strtoint(copy(sl4[sl4.Count-1],0,100))+1-Length(ListBox2.Items[i]))+'#';
sl2.Clear;
sl4.Clear;
//----------------------------------------------------------------------------
x := 0;
for i := sl_2.Count-1 downto 0 do
begin
if copy(sl_2[i],0,2) = ' ' then inc(x);
if copy(sl_2[i],0,2) = ' ' then sl_2.Delete(i);
end;
for i := 1 to x do sl2.add('');
sl3.Text := sl2.Text + sl_2.Text;
for i := 0 to sl3.Count -1 do
sl4.Add(inttostr(length(sl3[i])));
sl4.Sorted := True;
for i := 0 to sl3.Count -1 do
sl3[i] := sl3[i] + StringOfChar(' ',strtoint(copy(sl4[sl4.Count-1],0,100))+1-Length(sl3[i]))+'#';
for i := 0 to ListBox2.Items.Count -1 do
ListBox2.Items[i] := ListBox2.Items[i] + sl3[i];
sl2.Clear;
sl4.Clear;
//----------------------------------------------------------------------------
x := 0;
for i := sl_3.Count-1 downto 0 do
begin
if copy(sl_3[i],0,2) = ' ' then inc(x);
if copy(sl_3[i],0,2) <> ' ' then sl_3[i] := sl_3[i];
end;
for i := 1 to x do sl2.add('');
sl3.Text := sl2.Text + sl_3.Text;
for i := 0 to sl3.Count -1 do
sl4.Add(inttostr(length(sl3[i])));
sl4.Sorted := True;
for i := 0 to sl3.Count -1 do
sl3[i] := sl3[i] + StringOfChar(' ',strtoint(copy(sl4[sl4.Count-1],0,100))+1-Length(sl3[i]))+'#';
for i := 0 to ListBox2.Items.Count -1 do
ListBox2.Items[i] := ListBox2.Items[i] + sl3[i];
sl.Free;
sl1.Free;
sl2.Free;
sl3.Free;
sl4.Free;
sl_1.Free;
sl_2.Free;
sl_3.Free;
Oki poradziłem a teraz wezmę rady Olesia