row Border Coordinates of a radgridView

9 posts, 0 answers
  1. Vishal
    Vishal avatar
    10 posts
    Member since:
    Sep 2012

    Posted 16 Nov 2012 Link to this post

    Hi,

    How to get the  row Border Coordinates of a gridView for a winform application.

    Regards,
    Vishal
  2. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 16 Nov 2012 Link to this post

    Hello,

    What do you mean by row border coordinates? Location of the control inside a form?

    Best Regards,
    Emanuel Varga
    WinForms MVP
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Vishal
    Vishal avatar
    10 posts
    Member since:
    Sep 2012

    Posted 16 Nov 2012 Link to this post

    Hi,

    We have 2 gridVIew on the same screen separated by the panel. we need to draw a line between rows of the grids based on the row data; 

    Since gridview also have scroll bars attached to it. so when row is scrolled, i wish to have running coordinates of the row, in that way. on paint event a line will be re-drawn the moment row is scrolled.

    for that purpose i need to have border co-ordinates of the row, 

    Thanks,
    Vishal
  5. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 16 Nov 2012 Link to this post

    Can you please add a screenshot?

    Best Regards,
    Emanuel Varga
    WinForms MVP
  6. Vishal
    Vishal avatar
    10 posts
    Member since:
    Sep 2012

    Posted 16 Nov 2012 Link to this post

    Hi,

    screenshots cannot be placed, but can you tell me on how to have coordinates of  a row on rowformatting event.

    I have placed screenshot now, with lines been drawn, but as you can see when the scroll event will fire, as the coordinates are static; the lines will not be re-drawn. I want to re-draw lines against the mapped rows. so when the mapped rows are moved/ or are out of visible area. lines are again drawn; as row coordinates have changed.
  7. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 16 Nov 2012 Link to this post

    Hello again,

    You could try registering for the CellFormatting event and getting the Cell.LocationToControl,

    void grid_CellFormatting(object sender, CellFormattingEventArgs e)
    {
        e.CellElement.Text = e.CellElement.LocationToControl().ToString();
    }

    But from what i see it's not very reliable...

    Best Regards,
    Emanuel Varga
    WinForms MVP
  8. Plamen
    Admin
    Plamen avatar
    132 posts

    Posted 21 Nov 2012 Link to this post

    Hi guys,

    Thank you for writing.

    You could use the 'Paint' event for the drawing. In order to apply the new painting the panel should be re-painted. This can be achieved by calling its Invalidate method. The Invalidate method cause repainting of the whole control, which apparently raises the RowPaint event. Here is a sample demo:
    radPanel1.Paint += new PaintEventHandler(radPanel1_Paint);
    radGridView1.TableElement.VScrollBar.Scroll += new ScrollEventHandler(VScrollBar_Scroll);
     
    void radPanel1_Paint(object sender, PaintEventArgs e)
    {
        Graphics g = e.Graphics;
      
        foreach (GridRowElement row in radGridView1.TableElement.VisualRows)
        {
            GridDataRowElement dataRow = row as GridDataRowElement;
            if (dataRow != null)
            {
                Point location = dataRow.ControlBoundingRectangle.Location;
                g.DrawLine(Pens.Blue, 10, location.Y, 200, location.Y);
            }
        }
    }
     

    void VScrollBar_Scroll(object sender, ScrollEventArgs e)
    {
        radPanel1.Invalidate();
    }

    I hope that you find this information useful.

    Greetings,
    Plamen
    the Telerik team
    Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
  9. Vishal
    Vishal avatar
    10 posts
    Member since:
    Sep 2012

    Posted 21 Nov 2012 Link to this post

    Hi Plamen,

    Thanks for the response, and for the solution.  can you shae the sample application.

    Regards,
    Vishal Gupta
  10. Plamen
    Admin
    Plamen avatar
    132 posts

    Posted 22 Nov 2012 Link to this post

    Hi Vishal,

    Thank you for getting back to me.

    Please, find attached an example project where I have implemented a similar case to yours.

    I hope this will be useful. Should you have further questions, I would be glad to help.

    Greetings,
    Plamen
    the Telerik team
    Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
Back to Top
UI for WinForms is Visual Studio 2017 Ready