Checkbox celltype custom picture and locked cell

Posted by: david.sheppard on 13 August 2020, 5:05 am EST

    • Post Options:
    • Link

    Posted 13 August 2020, 5:05 am EST - Updated 30 September 2022, 4:26 am EST

    I am using a custom picture for the check box celltype. It works fine when the cell is not protected. When I protect the sheet the checkbox picture returns to the default.

    The attached picture shows the spread with the custom checkbox image in the first column. I locked the third row. When I protect the sheet the checkbox image returns to the default.

  • Posted 13 August 2020, 8:53 pm EST

    FYI. The reason that I am trying to use a custom picture is because users say that it is hard to see the checkbox value in locked cells.

    It would solve the root cause of my problem if the checkbox picture was bigger and scaled with the zoom like button cell types do when “PictureZoomEffect” is set to true. You can see from the screen capture that the checkbox image only takes up a small part of the cell. If the checkbox image was the height of the entire cell and scaled with the zoom, my issue would be solved.

  • Posted 14 August 2020, 3:28 am EST

    Hi David,

    Yes, I observe it too and it is a design behavior.

    The PaintCell of CheckBoxCellType is responsible for drawing the checkbox. When the sheet is protected or the control is disabled, SpreadView passes true for its isLocked parameter and when isLocked is true, PaintCell will draw the checkbox disabled when drawing the cell.

    So, you can create a custom CheckBoxCellType that overrides the default behavior and draws it normally instead.

    For this, you will need to override the PaintCell and define the value for isLocked as false in the call to the base class. The cells will draw as they would if they were not locked, but will still be locked from editing.

    public class CustomCheckboxCellType: FarPoint.Win.Spread.CellType.CheckBoxCellType {         public override void PaintCell(Graphics g, Rectangle r, FarPoint.Win.Spread.Appearance appearance, object value, bool isSelected, bool isLocked, float zoomFactor)         {             isLocked = false;             base.PaintCell(g, r, appearance, value, isSelected, isLocked, zoomFactor);         } }
    Also, you can set the disabled picture for the CheckBoxCellType object, as follows:```

    checkBoxCellType.Picture[CheckBoxPictureIndex.TrueDisabled] = (Image)Properties.Resources._checked;

    checkBoxCellType.Picture[CheckBoxPictureIndex.FalseDisabled] = (Image)Properties.Resources._unchecked;

    The dimension of the checkbox is determined by the Windows. To increase the height, you should set a custom image, using any of the methods above.
    
    Regards,
  • Posted 14 August 2020, 4:45 am EST

    Thank you the TrueDisabled and FalseDisabled is what I needed.

    Please pass on to your developers that they need to consider adding a PictureZoomEffect to the checkbox image.

    We have been using your product for over a decade and we have never received complaints about being able to see the checkbox images until now. Something has changed recently, either with Windows or with the computer monitors.

    Thanks again.

  • Posted 17 August 2020, 1:21 am EST

    Hi David,

    I have passed onto the enhancement request to the developers [ID: 10922]. The feature might be added in one of the future release versions, if the team finds it feasible.

    Thanks & Regards,

    Ruchir

  • Posted 7 November 2020, 7:49 pm EST

    Hi,

    I am happy to share that in the latest released v14 release a new property PictureZoomEffect is added to CheckBoxCellType which works same as ButtonCellType. You are suggested to verify the fixed behavior.```

    FarPoint.Win.Spread.CellType.CheckBoxCellType ckbxcell = new FarPoint.Win.Spread.CellType.CheckBoxCellType();

    ckbxcell.ThreeState = true;

    ckbxcell.Picture[FarPoint.Win.CheckBoxPictureIndex.TrueDisabled] = (Image)Properties.Resources._checked;

    ckbxcell.Picture[FarPoint.Win.CheckBoxPictureIndex.FalseDisabled] = (Image)Properties.Resources._unchecked;

    ckbxcell.Picture[FarPoint.Win.CheckBoxPictureIndex.True] = (Image)Properties.Resources._checked;

    ckbxcell.Picture[FarPoint.Win.CheckBoxPictureIndex.False] = (Image)Properties.Resources._unchecked;

    ckbxcell.TextTrue = “Checked”;

    ckbxcell.TextFalse = “Unchecked”;

    ckbxcell.TextIndeterminate = “Not Sure”;

    ckbxcell.PictureZoomEffect = true;

    fpSpread1.ActiveSheet.Cells[1, 1].CellType = ckbxcell;

    
    Regards,
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels