I'd like to create a custom column chooser with a couple check boxes at the top. Is there a way to be able to do this? It seems to me that there should be a template that you can just add extra stuff to if you like.
I've been going through other posts on similar topics but they're all so old and I don't know what the current version can do.
Hello Sean,
Modifying a control can be done by utilizing the CreationFilter which all our controls have exposed. It allows you to add, replace or modify existing elements.
The issue here, is that i don't really see any space for these checkboxes you want to add. The control already have a logic to place all its children in the row container, as well as resizing implemented for them. Creating space for these checkboxes will interfere with both of the above implementations, so its likely that they may not work after that.
What i would suggest instead, is to create your own form, and add checkboxes or any other controls with the ColumnChooser in it. There is a sample in ours samples browser showing how to create a custom column chooser form and embed the column chooser control inside it.
Should you have any other questions, please let me know.
Sincerely,Tihomir TonevAssociate Software DeveloperInfragistics
Thanks for that. I was actually able to add what I needed by putting everything in a user control and docking it to the top of the ColumnChooser form. However, the one issue I have now is accessing the rows in the ColumnChooser grid itself. One of my checkboxes is for Select All. How can I access those rows? I just can't find any properties for it, but it's possible with multi-select so it can be done.
What are your checkboxes doing? Sounds like you want one to do a "select all". What's the other one?
If you just want to check or uncheck all of the columns, there are easier ways than creating your own custom control. You could probably modify the dialog the grid shows with a little coding.
Anyway, if you want to loop through the rows in the ColumnChooser, you can do that. It helps to know that the list you are seeing inside the ColumnChooser control is actually an UltraGrid. So the only really tricky part is getting a reference to that grid and then you can loop through the rows or modify the grid however you want.
To get the grid, you can do something like this:
var columnChooserGrid = (UltraGrid)myColumnChooser.Controls.Find("displayGrid", true).First();
Hello,
I am glad to hear that you have resolved your issue.
If you would like to see a certain functionality implemented in our future releases, you can submit a feature request on our product ideas web site.
There are many benefits to submitting a product idea:
- Direct communication with our product management team regarding your product idea.
- Notifications whenever new information regarding your idea becomes available.
- Ability to vote on your favorite product ideas to let us know which ones are the most important to you. You will have ten votes for this and can change which ideas you are voting for at any time.
- Allow you to shape the future of our products by requesting new controls and products altogether.
- You and other developers can discuss existing product ideas with members of our Product Management team.
Furthermore, I would like to inform you that based on this thread after a discussion with our development team select/unselect functionality for all checkbox to the column chooser is included the backlog.
In order to check what new is available for new releases you can refer to the “What is new” section here.
Thank you for using Infragistics Components.
Ok, so I used the 2nd method and it works beautifully.
Thanks. Perhaps this can be made easier by providing us with a template that we can easily alter, perhaps even exposing some of this stuff in public methods.
Okay, I took another look and it seems like the Visible field is backed up by the actual Hidden property of the column. So changing it in code doesn't trigger a change to the actual Hidden property and the columnChooser grid just re-loads the value from the hidden property of the column immediately, So that won't work. So what you need to do is get the actual grid column associated with the row and set it's hidden property.
One way you could do that would be to get the "Value" column and look at it's ToString and then parse out the Key of the column by removing the brackets. That's kind of a hack, but it works in a simple case where you only have one band in your grid.
foreach (var row in this.columnChooserGrid.Rows) { var valueCell = row.Cells["Value"]; var columnBandHolder = valueCell.Value; var columnKey = columnBandHolder.ToString().Replace('{', '\0').Replace('}', '\0'); var gridColumn = this.ultraGrid1.DisplayLayout.Bands[0].Columns[columnKey]; gridColumn.Hidden = true; }
If you application has full trust, as most WinForms applications do, then you could take another approach. The Value cell contains an object of type ColumnBandHolder, which is internal. And it is on that object that the actual reference to the grid column is stored. So if you don't mind using reflection, a more reliable way to get the column would be like this:
foreach (var row in this.columnChooserGrid.Rows) { var valueCell = row.Cells["Value"]; var columnBandHolder = valueCell.Value; var valueProperty = columnBandHolder.GetType().GetProperty("Value"); var gridColumn = valueProperty.GetValue(columnBandHolder) as UltraGridColumn; gridColumn.Hidden = true; }
Seems right to me. It's not working?
Maybe put a breakpoint in there and examine the row.Cell["Value"].Value. I noticed that the column's datatype is string for some reason. So maybe you need to set it to a string. Seems weird.
Another possibility is that something else in the ColumnChooser is interfering with your code and not allowing you to change the value.
It could also be a timing thing. I assume this code is in the CheckedChanged event of a CheckBox? It won't work inside of UltraGrid1_BeforeColumnChooserDisplayed, because whatever you change in there will be overwritten when the column chooser initializes the state of the checkboxes. That happens later.
The other one does a deselect all. And currently I'm trying to actually get the checks to change and I can't seem to find the right code. Here's what I've got.
UltraGrid grid = (UltraGrid)col.Dialog.Controls.Find("displayGrid", true).First(); foreach (var row in grid.Rows) { row.Cells["Visible"].Value = false; }
Now as for what I'm doing with all this, I just want some more user friendly interaction. The UC I made is working out great. I just dock it at the top. I've attached a pic. I haven't gotten formatting down yet as I'm still getting it to work and I'll format and apply styles later.