geocoins-software
asked on
Arranging DBGrid Columns
I have a DBGrid on a form. Above it, I have a Listbox with the DBGrid's Column names listed.
To the right, I have an Up & Down button. (See code Below). These buttons allow me to change the order of the column names in the listbox.
I would also like to change the order of the DBGrid's Columns as well.
So, when I click the Up button. As the code shows, it will exchange the listbox item with the previous one. I need it to also change the actual Grids Column as well.
Same thing for Down button
thanks
To the right, I have an Up & Down button. (See code Below). These buttons allow me to change the order of the column names in the listbox.
I would also like to change the order of the DBGrid's Columns as well.
So, when I click the Up button. As the code shows, it will exchange the listbox item with the previous one. I need it to also change the actual Grids Column as well.
Same thing for Down button
thanks
procedure TfrmOptions.btnUpClick(Sender: TObject);
begin
lbxColumns.Items.Exchange(lbxColumns.ItemIndex, lbxColumns.ItemIndex-1);
lbxColumns.ItemIndex:= lbxColumns.ItemIndex - 1;
end;
procedure TfrmOptions.btnDownClick(Sender: TObject);
begin
lbxColumns.Items.Exchange(lbxColumns.ItemIndex, lbxColumns.ItemIndex+1);
lbxColumns.ItemIndex:= lbxColumns.ItemIndex + 1;
end;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
John