Set_cell(0, 15) paints the entire row

Posted by: arcady on 2 March 2022, 4:47 am EST

    • Post Options:
    • Link

    Posted 2 March 2022, 4:47 am EST

    Hello, all

    I have the following problem:

    I use the following line of code: set_cell(row, 18, CellSettings.flexcpbackcolor, Color.FromArgb(255,255,255,255))

    When row is greater than 0, then it works correctly, only the specified cell is made white.

    But when I specify row = 0, the entire row is painted.

    Is this a known issue? What can be done?

    Thank you

  • Posted 3 March 2022, 3:17 am EST

    Hi Arcady,

    I assume that row 0 is a fixed row (property “c1FlexGrid.Rows.Fixed” is not “0”)?

    In this case, the “set_cell” method probably modified the style “Fixed”, and thus the full header row is changed.

    To work around this, you have to create a custom cell style:

    
    CellStyle styleFixedNew = this.c1FlexGrid.Styles.Add("FixedNew", this.c1FlexGrid.Styles.Fixed);
    styleFixedNew.BackColor = Color.White;
    
    this.c1FlexGrid.SetCellStyle(0, 18, styleFixedNew);
    
    

    Hope this helps

    Wolfgang

  • Posted 4 March 2022, 6:03 am EST

    Hi,

    We could not replicate the behavior at our end. Kindly refer to the attached sample showing the behavior at our end. If you are doing something different, please share a sample or update the attached sample so that we can assist you further.

    This behavior might occur if you have applied the BackColor to a CellRange using the set_Cell method and then try to apply a different BackColor to a cell from that CellRange resulting in the change of BackColor of the whole range. This behavior is observed because when the set_Cell method is called for a cell range and the cells in that range do not have the same custom CellStyle associated with it, a new CellStyle is created and applied to it. After that when the color of a single cell from that range is changed, it affects the whole range as they are sharing the same CellStyle object. The attached sample shows this behavior as well. You can assign the color of each cell separately to avoid this behavior.

    Regards,

    Kartik

    SetCell_VSFG.zip

    PS. Thank you for the suggestions, Wolfgang!

Need extra support?

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

Learn More

Forum Channels