我試圖更改我的RadContextMenu
上的項目,具體取決於我的RadGridView
(編輯:OrderList
)中當前選定的行。如果當前行中的數據綁定項具有正確的屬性值,我希望啓用該項。RadContextMenu.DropDownOpened在更改RadGridView.CurrentRow之前調用
問題是,當我直接右擊一行打開RadContextmenu
CurrentRow
尚未更新,所以DropDownOpened
與舊行一起調用。 如果我離開單擊或雙擊右鍵單擊它工作正常。
這裏有點代碼:
OrderMenu.DropDownOpened += OrderMenu_DropDownOpened;
而且方法
private void OrderMenu_DropDownOpened(object sender, EventArgs e)
{
GoToParentOrderBtn.Enabled = GetSelectedOrder()?.ParentOrderId != null;
}
private OrderViewModel GetSelectedOrder()
{
return (OrderViewModel)OrderList.CurrentRow.DataBoundItem;
}
我提供了一個你的問題的答案:) –
可能重複[右鍵單擊上下文菜單爲datagridview](http://stackoverflow.com/questions/1718389/right -click-context-menu-for-datagridview) –
對不起 - 我應該指定我的gridview。我正在使用RadGridView – Larzix