Howdy,
I have tons of grids in our application. Every grid except one presents a Boolean or bit from SQL as a checkbox. This one gird that does not work shows True and False. When you click in the cell it then turns into a checkbox. How do I make it look like a checkbox like have on every other grid? I am not setting any special setting on the other grids for it to work.
Thanks,M
The grid will automatically show a checkbox for any field whose DataType is boolean. I'm not sure about a bit field, but as long as it's a Boolean in DotNet, it will default to CheckBox Style.
If it's not doing that, the something you are doing is overriding it. The obvious things to check would the Style or EditorComponent property of the column or cells.
From my experience with other grids in our application the 'bit' field, or the SQL equiv. of Boolean always translates to a checkbox. But the behavior on this one grid is such that the cell shows the word True and False. However when I click in the cell, it shows as a checkbox.
If I asked you how can I configure the cell to behave like that, how would I even do it?
Thanks,M.
Hello,
The most efficient way I can think of to have your column display true and false and then a checkbox when a given cell is active would be to use a ValueList and toggle the ColumnStyle enumeration from 'Checkbox' to 'Edit' in the AfterCellActivate and BeforeCellDeativate events.
I attached a sample demonstrating this. Keep in mind that the sample is designed to have the end-user to click once to activate the cell and then click again to update the checkbox. Let me know if you have any questions.
Hi MD,
I asked that question (how would you even do it) because I was trying to point out it would take some lines of code to achieve the functionality of what the grid is currently doing. I wanted to see though to see if I had anything remotely similar on the init of that grid of which I don't. No valuelist, no editor....just binding a view to the grid's datasource and setting activation and selection.
Maybe it is this though?
CellClickAction = Infragistics.Win.UltraWinGrid.CellClickAction.EditAndSelectText;
Going to try and comment that out and see what happens!
Unfortuantely the grid does not have this built in and would need some code to be set like the sample demonstrates to achieve the behavior you desire. You can submit a feature request on our ideas website.
I am not sure if you are actually reading my post.
Let me say this again.
I have a grid. I have no special code on that grid other than what I said in the previous post about the cell click action.
When the grid loads, it displays any Boolean value with test True/False.
When I click in the cell, I get a checkbox.
EVERY OTHER GRID IN MY ENTIRE APPLICATION OF WHICH THERE ARE 100 OF THEM AT LEAST DOES NOT BEHAVE THIS WAY.
Why, and how to I get it so that the grid only displays a checkbox JUST LIKE THE REST OF THE GRIDS DO.
I asked how would you even get a grid to behave this way so I could double check the settings of the grid to see that I don't have anything strange set.
Thanks,
M.
CellDisplayStyle is a performance optimization. By setting it to FormattedText, the grid cell display the text using a TextUIElement and does not use an editor in the cell. This can boost performance a little since it requires less elements to paint the cell, but you lose a little functionality, too, like CheckBoxes.
The property exists on the Column and the Override. So you can set it on each individual column or the band or the DisplayLayout.
If you are setting it on the Band or DisplayLayout's override, then it affects the whole grid, but you can still override it on each individual column.
There's no way to set a single property and have it apply to all checkbox columns, though. You would have to loop through your columns and set the property on each Checkbox column individually.
Hi Mike,
Thanks for responding that means a lot.
Yes when we leave the cell it goes back to being text. We are setting ONE of the columns though to be PlainText (e.Bands[0].Columns["qty'].CellDisplayStyle = x). Would that effect the entire grid?
Looking at the properties in the UI designer of that grid the display style is set to FormattedText....when I set that to Default BANG it works correctly!!!
Now...I don't know why we put formattedText...I can't remember (I have to research). If i have to set that back to FormattedText...can I just in the override method set the DispalyStyle for booleans to be default?
Thanks...finally this mystery is solved!
Hi,
What is the behavior you are getting, now? You say that the cell shows True/False as a string, but then when you click on the cell it changes to a CheckBox. Does it change back to a string when you leave the cell?
If so, then that seems to indicate that the cell is using different editors or controls depending on whether or not the cell is in edit mode.
You could achieve that by applying a ControlContainerEditor to the cell, either via the Editor or EditorComponent property of the column or cell, where your ControlConatinerEditor has a CheckBox or UltraCheckEditor as it's EditingControl and some other control (or nothing) assigned to the RenderingControl.
That seems unlikely, though, since you would have had to go out of your way to set that up.
Another possibility which seems much more likely and would be easier to overlook would be if you were setting the CellDisplayStyle property, either on the column or the Override for the band or layout. This property is an optimization that improves performance, but reduces the functionality of certain cells by bypassing the editor. A setting of CellDisplayStyle.PlainText results in exactly the behavior you describe here - assuming leaving the cell reverts to cell back to text.
Sorry I know this is a year old but we got busy with some other stuff but this is still an issue. Could there be some other setting that would create behavior in this way? How would I even get it to be this way if I wanted to?
I haven't reproduced the issue yet but I created a more simplfied sample that connects the UltraGrid to a local SQL Server Compact database file. I included a button to toggle the column style and the field in the dbo is a bit type.
Let me know if you have any questions. Please, if you can attempt to reproduce the behavior with this sample; send it back to us so I can investigate this further. Thanks.