Change order of DBGrid-columns (runtime!)

I am developping a adress-database-application. I want to change the order (sequence) of the columns during runtime. How can I fix that ???
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

ZifNabConnect With a Mentor Commented:
Hi rooSiedb,

juSt tried it on my D3, and it SeemS to work, probably it haS to do with my miStype :-)). here iS the correct Source. Sorry for any inconvinianceS.

procedure TForm1.Button1Click(Sender: TObject);
 Table1.Fields[4].index :=1

RegardS, Zif.
Hi roosiedb,

what about this? : Table1.Field[4].index:=0 (this will move it to column 0 in the DBGrid)

Regards, Zif.
roosiedbAuthor Commented:
Sorry, that won't work (maybe because I am using Delphi 3.0 ???).
Please help me with this...
roosiedbAuthor Commented:
Sorry, your answer really did not work. That was because you forgot the S in fieldS...

DBGrid1.Fields[0].Index := 2;

And I did not see the difference myself. When I copied and pasted your answer into my Delphi-application, it did not work at all. That's why I rejected your answer.
Now that you've found the error in your answer, I have fixed my problem.
Next time: watch your spelling please... I am a beginning Delphi-programmer and I don't know how to spell all these Delphi-terms myself yet, because I did not use this one before... Anyway, thank you very much for helping. I will increase and grade the answer now. Bye. J.v.Barchum.
no problem...  I'll try to do my best with the syntaxes. But after all E-E is intended to communicate with each other. So, these errors aren't a world-crime... except the time you lose with it... thanks! c.u. ZiF.
All Courses

From novice to tech pro — start learning today.