Search code examples
c#.netvb.netc1flexgrid

Hiding a particular cell based on row and column in flexgrid


I have a flexgrid (flex component grid), how do i hide a cell.

For ex: 2nd row and 5th column - i need to hide/remove based on some condition.

for say

if(C1FlexGrid1.Rows[2][5].ToString().Length <0)
{
  //I want this to be invisible.
  C1FlexGrid1.Rows[2][5].isVisible=false;
}

There is no propery that supports isVisible the way i have used. Any way i can achieve this ? Thanks.


Solution

  • Finally i figured it out:

    Create a ownerdrawcell event for your winforms component grid:

    componentGrid.DrawMode = C1.Win.C1FlexGrid.DrawModeEnum.OwnerDraw;
    componentGrid.OwnerDrawCell += componentGrid_OwnerDrawCell;
    

    Method

    void componentGrid_OwnerDrawCell(object sender, C1.Win.C1FlexGrid.OwnerDrawCellEventArgs e)
    {
           var value = componentGrid.GetCellCheck(e.Row,e.Col);
           //Your custom condition
           if (value is bool)
           {
              //Will hide the cell
              e.Style.Display = DisplayEnum.None;
           }
           else
           {
               //Will show the cell  
               e.Style.Display = DisplayEnum.Stack;
           }
    }