how to move 'delete row' menu item to bottom of context menu?

1 Answer 49 Views
ContextMenu GridView
Gone2TheDogs
Top achievements
Rank 1
Iron
Veteran
Gone2TheDogs asked on 23 Aug 2023, 10:05 PM

how do I move the pre-built "Delete Row" option to the bottom or move my options to the top?


		private void dgvSIQ_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e)
		{
			RadMenuItem mniProcess = new RadMenuItem();
			RadMenuItem mniVendorInquiry = new RadMenuItem();
			RadMenuSeparatorItem mniSeparate = new RadMenuSeparatorItem();

			e.ContextMenu.Items[0].Visibility = ElementVisibility.Collapsed;
			e.ContextMenu.Items[1].Visibility = ElementVisibility.Collapsed;

			mniProcess.Text = "Process PO";
			mniVendorInquiry.Text = "Vendor Inquiry";
			//e.ContextMenu.Items.Add(mniSeparate);
			e.ContextMenu.Items.Add(mniVendorInquiry);
			e.ContextMenu.Items.Add(mniProcess);

			try
			{
				mniProcess.Click += mniProcess_Click;
				mniVendorInquiry.Click += mniVendorInquiry_Click;
			}
			catch (Exception)
			{
			}

		}

1 Answer, 1 is accepted

Sort by
0
Accepted
Dinko | Tech Support Engineer
Telerik team
answered on 24 Aug 2023, 11:01 AM

Hello Bob,

Thank you for the provided details.

You can remove the RadMenuItem for the delete row option and add it last.

private void RadGridView1_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e)
{
    RadMenuItem mniProcess = new RadMenuItem();
    RadMenuItem mniVendorInquiry = new RadMenuItem();
    RadMenuSeparatorItem mniSeparate = new RadMenuSeparatorItem();

    e.ContextMenu.Items[0].Visibility = ElementVisibility.Collapsed;
    e.ContextMenu.Items[1].Visibility = ElementVisibility.Collapsed;

    mniProcess.Text = "Process PO";
    mniVendorInquiry.Text = "Vendor Inquiry";
    //e.ContextMenu.Items.Add(mniSeparate);
    RadMenuItem deleteRow = e.ContextMenu.Items[2] as RadMenuItem;
    e.ContextMenu.Items.Add(mniVendorInquiry);
    e.ContextMenu.Items.Add(mniProcess);
    e.ContextMenu.Items.RemoveAt(2);
    e.ContextMenu.Items.Add(deleteRow);

    try
    {
        mniProcess.Click += mniProcess_Click;
        mniVendorInquiry.Click += mniVendorInquiry_Click;
    }
    catch (Exception)
    {
    }
}

Here is the result:

Regards,
Dinko | Tech Support Engineer
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Gone2TheDogs
Top achievements
Rank 1
Iron
Veteran
commented on 24 Aug 2023, 11:09 AM

Thank you, Dinko.

Tags
ContextMenu GridView
Asked by
Gone2TheDogs
Top achievements
Rank 1
Iron
Veteran
Answers by
Dinko | Tech Support Engineer
Telerik team
Share this question
or