The following code mainly completes the settings in the DBGRID, and the columns in the DBGRID are displayed.
// Initialize the list of PopupMenu Procedure InitMenuItem; var newItem: tMenuItem; I: integer; begin for i: = 0 to dbgrid1.columns.count-1 do begin newItem: = tMenuItem.create (nil); newItem.caption: = DBGRID1.COLUMNS.ITEMS [i] .title.caption; new method for pop-up menu child; popupmenu1.items.add (new; end;);
Procedure Menuonclick (Sender: TOBJECT); Begin Tmenuitem (Sender) .Checked: = NOT TMENUITEM (Sender) .CHECKED; DBGRIDDISPLAYINF; End;
procedure DBGridDisplayInf; var i: integer; begin for i: = 0 to PopupMenu1.Items.Count-1 do begin if not PopupMenu1.Items [i] .Checked then DBGrid1.Columns.Items [i] .Visible: = false else DBGrid1 .Columns.Items [i] .visible: = true; end;