Is it possible to change the RadFormTitleBarElement default context menu (Minimize, Maximize, Restore, etc.) for a customized one? I have seen that RadTitleBar has a ContextMenuProperty property exposed, but I cannot find it in my RadForm embebed title bar.
Thank you very much.
2 Answers, 1 is accepted
0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 29 Sep 2020, 12:17 PM
Hello, JoaquĆn,
I suppose that you want to replace the following context menu:
Indeed, RadTitleBar has a dedicated property for the context menu. However, RadForm internally uses a RadTitleBarElement and the context menu illustrated above comes from a core logic. You can replace the default context menu of the Operating System, by extending RadForm and overriding the WndProc method. If the message is WM_CONTEXTMENU, you should create and show your own context menu.
publicpartialclassRadForm1 : Telerik.WinControls.UI.RadForm
{
publicRadForm1()
{
InitializeComponent();
}
publicconstint WM_CONTEXTMENU = 0x7b;
protectedoverridevoidWndProc(ref System.Windows.Forms.Message m)
{
if (m.Msg == WM_CONTEXTMENU)
{
RadContextMenu menu = new RadContextMenu();
RadMenuItem item = new RadMenuItem("Restore");
item.Click += new EventHandler(item_Click);
menu.Items.Add(item);
RadMenuItem item1 = new RadMenuItem("Maximize");
item1.Click += new EventHandler(item1_Click);
menu.Items.Add(item1);
RadMenuItem item2 = new RadMenuItem("Minimize");
item2.Click += new EventHandler(item2_Click);
menu.Items.Add(item2);
menu.Show(this, PointToClient(Control.MousePosition));
return;
}
base.WndProc(ref m);
}
voiditem1_Click(object sender, EventArgs e)
{
this.WindowState = FormWindowState.Maximized;
}
voiditem_Click(object sender, EventArgs e)
{
this.WindowState = FormWindowState.Normal;
}
voiditem2_Click(object sender, EventArgs e)
{
this.WindowState = FormWindowState.Minimized;
}
}
I hope this information helps. If you need any further assistance please don't hesitate to contact me.
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.