This is a migrated thread and some comments may be shown as answers.

Drop Down List not saving/triggering selection until clicking drop down arrow again

3 Answers 31 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Brady
Top achievements
Rank 1
Brady asked on 10 Aug 2018, 06:45 PM

So here is my issue (I have searched in the forums and can't find an answer)...

I have a RadDropDownList containing tuples of strings. When I click on the Drop Down List, I am expecting this method to be called right away, but once I select the option I want, I have to press the down arrow on the drop down again before it will call the JumpManager code at the bottom.

Basically I want the jumpmanager to be called when I select an option from the drop down, and not have to click the arrow again.

I have tried debugging but am failing to see how to fix it.

Any and all help would be great. Thanks!

*****************************************

P.S. I am new to C# and winforms so that is part of the issue also. Please see attached screenshots to get a better idea of what I'm describing above. I want the new tab for the selection from the drop down list to open without having to click the drop down arrow again.

Thanks!

void mplSpecificDDL_Click(object sender, EventArgs e)
       {
           //cast sender object to type RadDropDownList
           RadDropDownList snd = sender as RadDropDownList;
 
           int i = snd.SelectedIndex;
           Console.Write(snd.SelectedItem);
            
           //if it's a valid click...
           if (i >= 0)
           {
               //get the mpl id for the MPL date range selected
               int mplid = tmpDDL_MPLLists[i].Id;
               FactoryOrder myOrder = new FactoryOrder();
               //create an order tuple to open the specific MPL page we want to view
               myOrder.AddOrderLine("SpecificList", mplid.ToString());
 
               //jump manager to pull up a specific MPL window tab
               JumpOrder myJumpOrder = new JumpOrder();
               myJumpOrder.factoryOrder = myOrder;
               myJumpOrder.module = "MPL";
               myJumpOrder.targetWin = "MPLS";
 
               //issue: new MPLS window only opens when
 
               MainDockWin.mainJumpManager.PassJumpOrder(myJumpOrder);
               MainDockWin.mainJumpManager.GoToWindow();
           }
       }

3 Answers, 1 is accepted

Sort by
0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 13 Aug 2018, 11:25 AM
Hello, Brady,      

If I understand your requirement correctly you want to detect when the user clicks a drop down item from the context menu in RadGridView. For this purpose, you can use the RadDropDownList.SelectedIndexChanged event. However, if you select an item once and then you select it again, the SelectedIndexChanged event won't be fired because the the selection is not actually changed. This case can be covered by handling the RadDropDownList.ListElement.MouseDown event and get the element under the mouse. Here is demonstrated a sample code snippet:

private void radGridView1_ContextMenuOpening(object sender, Telerik.WinControls.UI.ContextMenuOpeningEventArgs e)
{
    RadMenuItem menuItem = new RadMenuItem();
    menuItem.Text = "Open Specific Master Price List";
 
    RadDropDownList fontDropDownList = new RadDropDownList();
    fontDropDownList.SelectedIndexChanged += fontDropDownList_SelectedIndexChanged;
    fontDropDownList.ListElement.MouseDown += ListElement_MouseDown;
    fontDropDownList.Text = "Select Font";
    fontDropDownList.Items.Add(new RadListDataItem("Arial"));
    fontDropDownList.Items.Add(new RadListDataItem("Tahoma"));
    fontDropDownList.Items.Add(new RadListDataItem("Times New Roman"));
    fontDropDownList.Items.Add(new RadListDataItem("Verdana"));
 
    RadMenuContentItem contentItem = new RadMenuContentItem();
    RadHostItem host = new RadHostItem(fontDropDownList);
    contentItem.ContentElement = host;
 
    contentItem.AutoSize = false;
    contentItem.Size = new System.Drawing.Size(150, 100);
    menuItem.Items.Add(contentItem);
    e.ContextMenu.Items.Add(menuItem);
}
 
private void ListElement_MouseDown(object sender, MouseEventArgs e)
{
    RadListElement el = sender as RadListElement;
    RadListVisualItem visualItem = el.ElementTree.GetElementAtPoint(e.Location) as RadListVisualItem;
    Console.WriteLine("Clicked item: " + visualItem.Data.Text);
}
 
private void fontDropDownList_SelectedIndexChanged(object sender, Telerik.WinControls.UI.Data.PositionChangedEventArgs e)
{
    RadDropDownList list = sender as RadDropDownList;
    if (list != null && e.Position > -1)
    {
        Console.WriteLine("New Selected Item: " + list.Items[e.Position]);
    }
}



If it is not the exact requirement it would be greatly appreciated if you can provide more details about the exact requirement that you are trying to achieve. A sample project demonstrating the undesired behavior would be also very useful. Thus, we would be able to think about a suitable solution and assist you further. Thank you in advance.

I hope this information helps. If you have any additional questions, please let me know.  
 
Regards,
Dess
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Brady
Top achievements
Rank 1
answered on 13 Aug 2018, 01:11 PM
Thank you so much for your response! I will attempt to implement this functionality and let you know if it does/does not work! 
0
Brady
Top achievements
Rank 1
answered on 13 Aug 2018, 02:17 PM
Works great, I just needed the selectedindexchanged method and just implemented the jumping logic there. Thanks again! 
Tags
Menu
Asked by
Brady
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Brady
Top achievements
Rank 1
Share this question
or