[SOLVED] CheckBoxes in DataGridView cannot be checked/unchecked

Answered Closed
0
0

Hi,

I believe this is the same bug as reported by Wilfred. I have only been able to reproduce this with a custom theme we are using. It was working fine in 1.3.14 but is broken in 1.3.15. I have attached a project using the custom theme so you can test.

Thanks,
Robin.

  • You must to post comments
Best Answer
0
0

Hi Robin,

The project is using a very old theme definition, that’s what it causing the issue. Before this release the checkbox cell was a background image and then the DataGrid detected the click in the middle measuring the size of the image. One of the problems was that the background image needed also a padding and the padding prevented the cell to be resized smaller than the padding causing it to bleed over the next cell.

Now the grid cells are containers and the click inside is detected without measuring anything, it returns the role attribute of the inner element. This way we can easily detect t he inner checkbox image without caring about the coordinates, and we can also detect clicks on the +/- buttons for expandable rows (when they will be available), etc.

You can also detect clicks on custom elements, if you set the cell to AllowHtml and add “<span role=’MyItem1′>MyItem1</span><span role=’MyItem2′>MyItem2</span>” then you will find “MyItem1” or “MyItem2” in the new Role  property of the DGV and LV click event args.

Coming back to the issue at hand… 🙂

If you are just changing the colors it’s a lot easier to use a theme minx.

In your project:

  • In Web.config set the theme to “Classic-2”
  • Delete \Themes\TestDefault.theme
  • Create a new \Themes\TestDefault.mixin.theme
  • Copy the definition below in the mixin theme file:
{
 "name": "TestDefault",
   "colors": {
     "activeBorder": "LightSteelBlue",
     "buttonText": "Black",
     "controlText": "Black"
 }
}

These are the changes I could spot over the default theme.

Now you can select any theme and Wisej will simply override the settings in the mixin. See this example: http://demo.wisej.com/apps/userdesktop

The theme buttons are RadioButtons with their AppearanceKey property set to “theme-button” and themed using a mixin like this:

{
 "appearances": {
   "theme-button": {
     "inherit": "button",
       "states": {
         "default": {
           "styles": {
             "backgroundColor": "rgba(0,0,0,.5)",
             "radius": 0
           },
           "properties": {
             "textColor": "white"
           }
       },
       "checked": {
         "styles": {
           "backgroundColor": "black"
         }
       }
     }
   }
 }
}

Best,
Luca

  • Robin Lao
    Hi Luca, Thanks so much for the detailed explanation. The mix-in for the colors works great. There’s just one oddity I found… or maybe it’s supposed to work this way. I put the TestDefault.mixin.theme file in the Themes folder and set ‘controlText’ to ‘Red’ (just to show the difference more clearly). I created a new form and placed a Label on it. The ForeColor of the label was NOT red, however if you go to the properties for the label the ‘ForeColor’ is set to @controlText and displays the red color in the property window. If you then choose any other ForeColor and then change back to @controlText the label’s ForeColor is then displayed properly in red. By changing the color to something else and then switching back the color, the designer adds the following code: this.label1.ForeColor = System.Drawing.Color.FromName(“@controlText”); I assume this line is missing when you first place the control on the form since the default value for ForeColor is ‘@controlText’. I’m not sure if this can be ‘fixed’ or not? it’ not a big deal.. we can go through all the forms and do the ‘switching’ trick! Thanks again for all your help. Robin
  • You must to post comments
Showing 1 result