unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
cxDataStorage, cxEdit, DB, cxDBData, cxGridCustomTableView,
cxGridTableView, cxGridDBTableView, cxGridCustomPopupMenu,
cxGridPopupMenu, cxGridLevel, cxClasses, cxControls, cxGridCustomView,
cxGrid, cxGridStdPopupMenu;
type
TMenuStringForCxGrid = class(TObject)
class procedure HeaderMenuProc(Sender:TObject);
end;
type
TForm1 = class(TForm)
cxGrid1: TcxGrid;
cxGDBTV1: TcxGridDBTableView;
cxGLv1: TcxGridLevel;
cxGDBTV1Column1: TcxGridDBColumn;
cxGDBTV1Column2: TcxGridDBColumn;
cxGDBTV1Column3: TcxGridDBColumn;
cxGridPopupMenu1: TcxGridPopupMenu;
procedure cxGridPopupMenu1Popup(ASenderMenu: TComponent;
AHitTest: TcxCustomGridHitTest; X, Y: Integer;
var AllowPopup: Boolean);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
function PopCxGridMenuProc(ASenderMenu: TComponent):boolean;
implementation
{$R *.dfm}
class procedure TMenuStringForCxGrid.HeaderMenuProc(Sender: TObject);
var
HM:TcxGridStdHeaderMenu;
begin
HM:=TcxGridStdHeaderMenu(Sender);
if HM.Items.Count<>17 then exit;
HM.Items[0].Caption:='&'+'遞增排序';//遞增排序
HM.Items[1].Caption:='&'+'遞減排序';//
HM.Items[2].Caption:='&'+'取消排序';//
HM.Items[4].Caption:='&'+'以此欄位分組';//
HM.Items[5].Caption:='&'+'分組視窗';//
HM.Items[6].Visible:=false;
HM.Items[7].Visible:=false;
HM.Items[8].Visible:=false;
HM.Items[10].Caption:='&'+'隱藏此欄位';//
HM.Items[11].Caption:='&'+'欄位選擇視窗';//
HM.Items[13].Visible:=false;
HM.Items[14].Caption:='&'+'最適欄寬';//
HM.Items[15].Visible:=false;
HM.Items[16].Caption:='&'+'最適欄寬(所有欄位)';//
end;
function PopCxGridMenuProc(ASenderMenu: TComponent):boolean;
begin
if ASenderMenu is TcxGridStdHeaderMenu then
TcxGridStdHeaderMenu(ASenderMenu).OnPopup := TMenuStringForCxGrid.HeaderMenuProc;
result:=true;
end;
procedure TForm1.cxGridPopupMenu1Popup(ASenderMenu: TComponent;
AHitTest: TcxCustomGridHitTest; X, Y: Integer; var AllowPopup: Boolean);
begin
PopCxGridMenuProc(ASenderMenu);
end;
end.
星期三, 2月 18, 2009
cxgrid 欄位 重新排序的popmenu
表單上放上TcxGridPopupMenu元件
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言