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.
It is really hard for me to attach my project as it is a heavily integrated system with a couple hundred thousand lines of code + Database.
Sorry, 1st post is the picture when you click in the cell, here it is when out of the cell.
Still the same!
Hello,
It's quite strange if you are not setting this style to anything else at any point. In my sample you can see that I had to use a few events to set up this behavior for a boolean column. What is the type for your "Taxable?" column?
Hi,
In SQL it is:
Bit, Not Null Default 0
The grid has it as a Boolean.
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!
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.