FlexGrid for WinForms

how to draw a line between two specified cells

  •  26334980 said 12 months ago:

    want to draw a line between two specified cells with a zero in,
    thanks for your help
    Kerry

    Attachments:
    You must be logged in to view attched files.
  •  Mohita24p said 12 months ago:

    Hello,

    In order to draw line around the cells having zero, you need to make use of the OwnerDrawCell event of C1FlexgRid. A sample is also available for your reference and the same can be downloaded from the following link :

    http://our.componentone.com/samples/winforms-ownerdraw

    You can also refer to the one of the similar forum issue :

    http://our.componentone.com/groups/winforms/flexgrid-for-winforms/forum/topic/43315

    Hope it helps! Let us know if you still face any issues.

    Regards,
    Mohita

  •  26334980 said 12 months ago:

    two samples are both not my desire, my desire is like the following

    draw a line from a cell center to another cell center which has a zero

    i don’t know how to write code.

    Attachments:
    You must be logged in to view attched files.
  •  Anupam_P16p said 12 months ago:

    Hi,

    You need to implement this in OwnerDrawCell event of the grid. Now, to get it triggered, you need to set DrawMode property of the grid to OwnerDraw. Then use this code:

            Point pt1;
            Point pt2;
    
            void c1FlexGrid1_OwnerDrawCell(object sender, C1.Win.C1FlexGrid.OwnerDrawCellEventArgs e)
            {
                if (pt2 != null)
                {
                    pt1 = pt2;
                    if (e.Text.Contains("0″))
                    {                    
                        Rectangle rect = e.Bounds;
                        pt2 = new Point(rect.Left + rect.Width / 2, rect.Top + rect.Height / 2);
                        e.Graphics.DrawLine(new Pen(Brushes.Black), pt1, pt2);                 
                    }                
                }
            }
    

    And then you get lines connecting center coordinates of cells like the screen shot.

    Cheers,
    Anupam.

    Attachments:
    You must be logged in to view attched files.
    Answer
Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.