How to detect when Column Chooser is opened?

13 posts, 1 answers
  1. Phi
    Phi avatar
    47 posts
    Member since:
    Dec 2008

    Posted 30 Oct 2010 Link to this post

    I have 2 RadGridView controls on the same form using RadDock to host them both. On one grid, I allowed Column Chooser. The other grid, I do not. When switching between the two grids, the column chooser still visible when going to the grid that does not allow column chooser. How do I detect whether the Column Chooser is opened so I could close/hide it when needed?

    PS: This is another weird thing: when I switched to the 2nd grid (which does not allow column chooser), I am able to drag the column header(s) to the column chooser to hide the column(s). The column(s) did disappear but nothing is showed on in the column chooser. There is no way to restore the hidden column(s) back!

    Thanks,

    Phi
  2. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 01 Nov 2010 Link to this post

    Hello,

    You can just use:
    if (grid.ColumnChooser.Visible)
    {
        // do something or
        grid.ColumnChooser.Close();
    }

    Hope this helps, if you have any other questions or comments, please let me know,

    Best Regards,
    Emanuel Varga
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Phi
    Phi avatar
    47 posts
    Member since:
    Dec 2008

    Posted 01 Nov 2010 Link to this post

    The funny thing is: The visible property equaled to true when going to a grid that allows column chooser. When switching to a grid that does not allow column chooser, the visible property is equaled to false but the darn column chooser is still visible. This indicated that each grid has its own column chooser. I just have to work around it in the changing event instead in the changed event.

    Thanks,

    Phi
  5. Answer
    Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 02 Nov 2010 Link to this post

    Hello again,

    Sorry i have oversimplified things... But i was thinking something you were doing some checks when you are switching tabs and just wanted to know how to close it.
    Anyway, i would propose two options:
    1. Whenever you switch tabs, just check if column chooser is visible and close it if it is (simplest one)
    2. If you only have 2 grids, you could handle the GotFocus event of both of the grids, and check if the other one has the column chooser open (ugly solution but i will work the same) and then close it.

    Hope this helps, if you have any other questions or comments, please let me know,

    Best Regards,
    Emanuel Varga
  6. Jack
    Admin
    Jack avatar
    2335 posts

    Posted 03 Nov 2010 Link to this post

    Hi Phi,

    I confirm the issue, we will address it in our upcoming Q3 release which will be available in the end of the next week. I hope this time frame is acceptable for you. If you have further questions, do not hesitate to ask.

    Regards,
    Jack
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. Phi
    Phi avatar
    47 posts
    Member since:
    Dec 2008

    Posted 03 Nov 2010 Link to this post

    I have no problem with the time frame. I know there is a lot of work involved in something like this. Just want to point out things so you guys could fix or improve your products. Ha ha, in another thought, you may want to get better testers :)
  8. Jack
    Admin
    Jack avatar
    2335 posts

    Posted 09 Nov 2010 Link to this post

    Hi Phi,

    Thank you for your feedback. We take seriously all issues reported by our customers and we will appreciate any ideas on how to improve our products. 

    If you have any other ideas or feedback, please do not hesitate to share them with us.

    Best wishes, Jack
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  9. Ofer
    Ofer avatar
    19 posts
    Member since:
    Jan 2012

    Posted 19 Jan 2012 Link to this post

    Hi Jack.
    I work in Q3.
    1. is there any  way to catch the columnchooser event  when its opened but not only at the first time?
    2. is there any  way to catch the columnchooser event  when column drags in to it? 
    i tried the got-Focus and the load and the shown  and the visible  etc for 1 and all the drag-event-Handler for 2. no one works
    The thing is that i have 2 Grids that are same and i want that when the user opened one columnchooser the other will opened as well and when he drag drop a column i want to drag for him the same column as well from the other grid to it's own columnchooser.
    the problem is that i can't find event that occurs when the drag-and-drop finished (DragDrop doesn't work )  

    thanks Ofer
  10. Nikolay
    Admin
    Nikolay avatar
    1803 posts

    Posted 19 Jan 2012 Link to this post

    Hello Ofer,

    Before addressing your questions, we would kindly ask you to provide the information that we requested in your thread "Borders and RTL in Export to excel". After we receive and confirm the information that you will provide there, we will be able to assist you further.

    Kind regards,
    Nikolay
    the Telerik team

    SP1 of Q3’11 of RadControls for WinForms is available for download (see what's new).

  11. Ofer
    Ofer avatar
    19 posts
    Member since:
    Jan 2012

    Posted 19 Jan 2012 Link to this post

    Hi Nikolay,
    I am licensed now.
    Can you please help me.
    Ofer.
  12. Ofer
    Ofer avatar
    19 posts
    Member since:
    Jan 2012

    Posted 23 Jan 2012 Link to this post

    Hi again  Nikolay,
    You told me that if i'll be register and licensed you will help me.  
    I already told  you that i did what you asked me. You can check it.
    So can you please help me 
    Ofer. 
  13. Jack
    Admin
    Jack avatar
    2335 posts

    Posted 24 Jan 2012 Link to this post

    Hi Ofer,

    Thank you for updating your account details. Directly to your questions:

    1. RadGridView creates a new column chooser every time when opening it. The best option in this case is to replace the default menu item with a custom one and attach to the Shown event every time when showing the column chooser:

    this.radGridView1.ContextMenuOpening += new ContextMenuOpeningEventHandler(radGridView1_ContextMenuOpening);
     
    void radGridView1_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e)
    {
        string columnChooserMenuItem = Telerik.WinControls.UI.Localization.RadGridLocalizationProvider
                .CurrentProvider.GetLocalizedString(Telerik.WinControls.UI.Localization.RadGridStringId.ColumnChooserMenuItem);
     
     
        int i = 0;
        foreach (RadMenuItemBase item in e.ContextMenu.Items)
        {
            if (item.Text == columnChooserMenuItem)
            {
                e.ContextMenu.Items.RemoveAt(i);
                RadMenuItem newColumnChooserMenuItem = new RadMenuItem(columnChooserMenuItem);
                newColumnChooserMenuItem.Click +=new EventHandler(newColumnChooserMenuItem_Click);
                e.ContextMenu.Items.Insert(i, newColumnChooserMenuItem);
                break;
            }
            i++;
        }
    }
     
    void newColumnChooserMenuItem_Click(object sender, EventArgs e)
    {
        this.radGridView1.ColumnChooser.Shown += new EventHandler(ColumnChooser_Shown);
        this.radGridView1.ShowColumnChooser(this.radGridView1.CurrentCell.ViewTemplate);
    }
     
    void ColumnChooser_Shown(object sender, EventArgs e)
    {
        GridViewColumnChooser columnChooser = (GridViewColumnChooser)sender;
        columnChooser.Shown -= new EventHandler(ColumnChooser_Shown);
        MessageBox.Show("Text");
    }

    2. In this case you should get the RadDragDropService from GridViewElement property by using the GetService method. Then you should handle the PreviewDragDrop event. Here is a sample:

    RadDragDropService dragDropService = this.radGridView1.GridViewElement.GetService<RadDragDropService>();
    dragDropService.PreviewDragDrop += new EventHandler<RadDropEventArgs>(dragDropService_PreviewDragDrop);
     
    void dragDropService_PreviewDragDrop(object sender, RadDropEventArgs e)
    {
        ColumnChooserVisualElement element = e.HitTarget as ColumnChooserVisualElement;
        if (element != null)
        {
            MessageBox.Show("Dropped!");
        }
    }

    You can get the dragged column by accessing the e.DragInstance property.

    Please, note that forum posts are handled within 72 hours and support tickets are handled according to your license agreement

    I hope this helps. If you need further assistance, do not hesitate to write back.
     
    All the best,
    Jack
    the Telerik team

    SP1 of Q3’11 of RadControls for WinForms is available for download (see what's new).

  14. Ofer
    Ofer avatar
    19 posts
    Member since:
    Jan 2012

    Posted 26 Jan 2012 Link to this post

    Thanks Jack.
Back to Top
UI for WinForms is Visual Studio 2017 Ready