我使用 Xtragrid。我想更改默认的弹出菜单 columnmenu GridViewColumnMenu 并添加 ColorPieker 和 FontEditor 以更改列中单元格的颜色和列的字体。添加到标准菜单栏的两个编辑器都失败了。更准确地说,添加了菜单项,但是通过单击它们,什么也没有发生。我还尝试使用编辑器将所有标准菜单项添加到菜单中,并将其全部显示在 barmanager 中。在这种情况下,作为颜色和字体选择的编辑器,但标准菜单(GridViewColumnMenu)项不起作用
if (e.MenuType == DevExpress.XtraGrid.Views.Grid.GridMenuType.Column)
{
DevExpress.XtraGrid.Menu.GridViewColumnMenu menu = e.Menu as GridViewColumnMenu;
// menu.Items.Clear();//Erasing the default menu items
if (menu.Column != null)
{
ClickedColumn = "";
ClickedColumn = menu.Column.FieldName;
DXPopupMenu dxPopupMenu = new DXPopupMenu();
dxPopupMenu.Items.Add(new DXEditMenuItem("Color",
new RepositoryItemColorEdit(),
new EventHandler(OnColumnsColorChanged),
null, null, 100, 0));
dxPopupMenu.Items.Add(new DXEditMenuItem("Font",
new RepositoryItemFontEdit(),
new EventHandler(OnColumnsFontChanged),
null, null, 100, 0));
DXPopupMenu sub = new DXPopupMenu();
sub.Caption = "FixedStyle";
sub.Items.Add(CreateCheckItem("Fixed None", menu.Column, FixedStyle.None, null));
sub.Items.Add(CreateCheckItem("Fixed Left", menu.Column, FixedStyle.Left, null));
sub.Items.Add(CreateCheckItem("Fixed Right", menu.Column, FixedStyle.Right, null));
dxPopupMenu.Items.Add(sub);
/*
DXPopupMenu dx = new DXPopupMenu();
dx.Caption = "dx";
foreach (DXMenuItem item in menu.Items)
{
dx.Items.Add(item);
}
//dxPopupMenu.Items.Add(dx);
*/
menu.Items.Clear();
Point p = e.Point;
// p.X += 210;
dxPopupMenu.MenuViewType = MenuViewType.Menu;
((IDXDropDownControl)dxPopupMenu).Show(barManager1, this, p);
试图同时显示菜单和菜单编辑器barmanager,一切正常。但有时菜单相互重叠并不容易。