This is a migrated thread and some comments may be shown as answers.

row Border Coordinates of a radgridView

8 Answers 187 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Vishal
Top achievements
Rank 1
Vishal asked on 16 Nov 2012, 10:59 AM
Hi,

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

Regards,
Vishal

8 Answers, 1 is accepted

Sort by
0
Emanuel Varga
Top achievements
Rank 1
answered on 16 Nov 2012, 11:05 AM
Hello,

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

Best Regards,
Emanuel Varga
WinForms MVP
0
Vishal
Top achievements
Rank 1
answered on 16 Nov 2012, 11:17 AM
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
0
Emanuel Varga
Top achievements
Rank 1
answered on 16 Nov 2012, 11:19 AM
Can you please add a screenshot?

Best Regards,
Emanuel Varga
WinForms MVP
0
Vishal
Top achievements
Rank 1
answered on 16 Nov 2012, 11:35 AM
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.
0
Emanuel Varga
Top achievements
Rank 1
answered on 16 Nov 2012, 12:23 PM
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
0
Plamen
Telerik team
answered on 21 Nov 2012, 09:22 AM
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.
0
Vishal
Top achievements
Rank 1
answered on 21 Nov 2012, 09:44 AM
Hi Plamen,

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

Regards,
Vishal Gupta
0
Plamen
Telerik team
answered on 22 Nov 2012, 03:44 PM
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.
Tags
GridView
Asked by
Vishal
Top achievements
Rank 1
Answers by
Emanuel Varga
Top achievements
Rank 1
Vishal
Top achievements
Rank 1
Plamen
Telerik team
Share this question
or