Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // load column titles with the column visibility state into the check list box
- var
- I: Integer;
- Index: Integer;
- begin
- CheckListBox.Clear;
- CheckListBox.Items.BeginUpdate;
- try
- for I := 0 to DBGrid.Columns.Count - 1 do
- begin
- Index := CheckListBox.Items.Add(DBGrid.Columns[I].Title.Caption);
- CheckListBox.Checked[Index] := DBGrid.Columns[I].Visible;
- end;
- finally
- CheckListBox.Items.EndUpdate;
- end;
- end;
- // set the columns visibility according to the check list box states; note that
- // the whole code shown here relies on the order of the items in the check list
- // box which cannot be changed (so you cannot use it for column reordering)
- var
- I: Integer;
- begin
- DBGrid.Columns.BeginUpdate;
- try
- for I := 0 to CheckListBox.Count - 1 do
- DBGrid.Columns[I].Visible := CheckListBox.Checked[I];
- finally
- DBGrid.Columns.EndUpdate;
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment