Dear All,
Given a grid with N(say 5) columns, and a method
SwapColumns(4,0) to
interchange the position of 5th column with 1st one, I
want to sort or
order the columns of the grid based on the items in a
certail list
ColOrder(TstringList) e.g 4,0,3,2,1
I tried this piece of code, but it's obviously not
working.
===========================================================
procedure TForm1.SortGridCols(ColOrder: TStringList);
var
iCol,i:smallint;
ColSwapped : TStringList;
begin
if not Assigned(ColSwapped) then
ColSwapped:=TStringList.Create;
with NSortGrid do
for i := 0 to ColCount-1 do
begin
iCol:=strToInt(Copy(ColOrder.Strings[i],6,Length(ColOrder.Strings
[i])));
if iCol <> i then {current odering is
different from desired}
begin
if (ColSwapped.IndexOf(inttostr(iCol))=-1)
and
(ColSwapped.IndexOf(inttostr(i))=-1) then
{Once swaped, will not be swaped again}
if
ColOrder.IndexOf(ColOrder.Strings[i])>-1 then
begin
SwapColumns(i,iCol);
//ColOrder.IndexOf
(ColOrder.Strings[i])
ColSwapped.Add(inttostr(iCol));
ColSwapped.Add(inttostr(i));
end;
end;
end;
FreeandNil(ColSwapped);
end;
===========================================================
Please advise,
Thanks & Regards,
Asim
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED]
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/delphi-en/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/