Delphi StringGrid CheckBox: Using Different Editors and Styles for Checkboxes
- maryjanehennig138v
- Aug 18, 2023
- 2 min read
I've modified the Delphi code found here to save the checkbox state in a three column stringgrid. The problem is that you have to click a cell twice in order to toggle it. If I set goEditing then you can set the state with one click but one more click makes the checkbox invisible. How can I prevent these edit state problems?
delphi StringGrid CheckBox
As the pictures show this works perfectly on windows 32. However not on Android. Indeed it has something to do with the style (checkcellstyle.checkboxchecked is never found). I can not find a working style for Android any suggestions?
One feature that can be very helpful in applications of the TStringGrid is having a checkbox column that either a user can click to signify their selection or used to show a certain state for some property. Adding this type of column is illustrated in this code. In the method 'InsertRowWithValues', the first column has '0' shown in the first part of the code when files containing 'VIDEO_TS*' are being selected. The '0' is illustrating the boolean state of a checkbox with 1 being checked and 0 unchecked. In selecting from the Object Inspector under StringGrid1-->Columns: TGridColumns-->0-Select in the TreeView, the ValueChecked and ValueUnchecked are shown. You can use other numbers, or have added code to change the state.
In this example the method InsertRowWithValues is used to add data to our StringGrid1 component. Each column's data is entered followed by a comma. It may be necessary to use typecasting functions to get data into a string format. Variables can be referenced, or simply shown as text as our '0' and '1' are for checkbox column.
I know that in the stringgrid, I can click on several items to select "multiple" items, BUT, if the user then accidentally clicks on another item, then it messes up the selections. They are too fragile and the user can mess up the selections without realizing it.
Afaik there's no "classic" way to do that (i'm working with 0.99.50.1189). In my case i've got to use a virtual table (TClientDataSet) with a boolean field that has a getter to avoid the "true" and "false" displayed text when linked with dbgrid. I've got to walk the dataset to obtain the values but i don't have to worry about the checkbox it does its job.You can try "BMUniDBGrid" too -new-bmunidbgrid-with-multiselection-rows-and-popupmenu-vers-098-and-099/ , i'm working with D2007 and i have no time to port it nor try it.Good luck.
Setting of control's IDs is done by FOR loop where particular controls are identified as CK1, CK2, CK3 and so on.We need to determine each checkbox because of consequent analysis what checkboxes were checked by user during the test.
Aprende sobre el elemento de interacción checkbox en Delphi 2010 el autor te expone lo correspondiente al tema, ayudándote a entender los pasos con ilustraciones, con las cuales aprenderás como usar adecuadamente en el programa Delphi 2010.
Thanks for your answer, DrawFrameControl and StyleServices.Enable do the work, thanks. But I still have the problem with Remote Desktop, in both cases with and without themes the owner drawed checkboxes are not displayed, but running the program in my computer works well, any ideas ? 2ff7e9595c
Comments