Ticket Q148554
Visible to All Users

Location BarButtonItem of a PopupMenu

created 16 years ago

Hi,
I have add to my project a PopupMenu with a BarButtonItem
When I open the PopupMenu (or when I click the BarButtonItem) I want to know the location where the PopupMenu was opened, but the EventArg (e) don't get this information…
Can You help me??
Thank You!!!

Comments (3)
DevExpress Support Team 16 years ago

    Hi Gabriele,
    Thanks for your question. I'm afraid that this problem is unclear to me. Why can't you use the coordinates that you have been passing when you call the PopupMenu.ShowPopup method? Basically, there is no easy way to obtain these coordinates from within the PopupMenu.Popup EventHandler. Please describe your goal in greater detail. I'll be happy to help you.
    Thanks,
    Uriah.

      Hi,
      I have added an attachment…
      In a scrollablecontrol I have a lot of controls…I want to add another control in the position where the PopupMenu is displayed, after you click the BarButtonItem "Nuovo".

      DevExpress Support Team 16 years ago

        Hi Gabriele,
        Again, the best and the most correct approach is to save the location of the popup menu in a global variable when showing it within the MouseUp event handler. Then, within the BarButtonItem.ItemClick event handler, simply use this location to add a new control to the form.
        There is also another approach - handle the BarButtonItem.ItemPressed event and obtain the PopupForm via Reflection. However, I suggest that you use this approach only if the above scenario isn't applicable in your situation. Here is a sample code, demonstrating how to implement this:

        C#
        private static int cnt = 0; private void OnBarButtonItemItemPress(object sender, ItemClickEventArgs e) { FieldInfo fi = typeof(PopupMenu).GetField("subControl", BindingFlags.Instance | BindingFlags.NonPublic); PopupMenuBarControl subControl = (PopupMenuBarControl)fi.GetValue(popupMenu1); Button btn = new Button(); btn.Name = string.Format("button{0}", cnt); cnt++; btn.Text = btn.Name; btn.Location = PointToClient(((IPopup)subControl).PopupForm.Location); Controls.Add(btn); }

        Please feel free to contact us again if you need any further assistance.
        Thanks,
        Uriah.

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.