Set or not to display the columns in DBGRID

xiaoxiao2021-03-06  77

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;

转载请注明原文地址:https://www.9cbs.com/read-93452.html

New Post(0)