Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
585
Adding a button to a Column Header
posted

I have a  Windows Form application with a basic grid of data.  I have enabled row filtering via the header icon.

My user has asked if I can add a button to the top of each column which allows them to copy the contents of the cell in the first row of that column to all the other cells in that column, and I'm trying to figure out the best way to accomplish this.

Can I add a custom button to a column header and create an event handler for it?

Or can I override the event hanlder for one of the other existing column header buttons?

Or can I freeze the first row so that it is unaffected by scrolling/filtering and add buttons to the cells in this row?

I guess the real question is "What is the best way to accomplish what I'm trying to do?"

Thanks so much!

Steve

Parents
No Data
Reply
  • 469350
    Suggested Answer
    Offline posted

    Hi Steve,

    Almost any of these would work. The cleanest solution would be the first one.

    sweeks said:
    Can I add a custom button to a column header and create an event handler for it?

    To do this, you would use a CreationFilter. CreationFilter's have a bit of a learning curve and they can be a bit daunting if you haven't used them before, but they are incredibly powerful tools and learning them is worth your while.

    Using a CreationFilter, you could add a ButtonUIElement into the HeaderUIElement and adjust the other UIElements within the header to make room for it.

    If you want to explore CreationFilters, I recomend that you search the Infragistics Knowledge Base for CreationFilter and you will find lots of sample - some of which may be pretty similar to what you want to do. Also, I strongly recommend that you get the Infragistics UIElementViewer Utility. It's very useful when dealing with UIElements.

    If you don't want to go that route, then the next best thing would be:

    sweeks said:
    Or can I freeze the first row so that it is unaffected by scrolling/filtering and add buttons to the cells in this row?

    You can fix a row in the grid by simply setting the Fixed property on the row. You could loop through the cells in the row and set the Style on each cell to Button.

    Also, the row will still be filtered out as normal. So you would need to handle the FilterRow event of the grid and prevent this row from being filtered.

Children