leejs 님, 안녕하세요.
그레이프시티입니다.
선택한 셀의 뷰포트 기준 Location을 찾기 위해서는, SpreadView.GetCellRectangle 메소드와 Point.Offset 메소드를 사용하실 수 있습니다.
하기 샘플 코드에서는 배경 이미지가 있는 사각형 도형을 마우스 클릭으로 선택된 셀에 추가하고 있습니다. 이때, SpreadView.FetCellRectangle(...).Location으로 선택된 셀의 좌표(Spread 컨트롤 기준)를 구한 후, Point.Offset 메소드를 사용하여 좌표를 뷰포트의 좌표로 변환합니다.
private void Form1_Load(object sender, EventArgs e)
{
fpSpread1.CellClick += FpSpread1_CellClick;
}
private void FpSpread1_CellClick(object sender, FarPoint.Win.Spread.CellClickEventArgs e)
{
FarPoint.Win.Spread.DrawingSpace.RectangleShape rShape = new FarPoint.Win.Spread.DrawingSpace.RectangleShape();
rShape.Width = 100;
rShape.Height = 100;
rShape.BackgroundImage = new FarPoint.Win.Picture(Image.FromFile("D:\\test\\image.png"));
// 선택한 셀의 좌표(Spread 기준)를 가져옵니다.
Point cellLocation = e.View.GetCellRectangle(0, 0, e.Row, e.Column).Location;
// 셀 좌표를 뷰포트 기준의 좌표로 변환합니다.
cellLocation.Offset(-e.View.GetViewportX(e.View.GetActiveRowViewportIndex()), -e.View.GetViewportY(e.View.GetActiveColumnViewportIndex()));
rShape.Location = cellLocation;
fpSpread1.ActiveSheet.AddShape(rShape);
}
추가로 궁금하신 사항이 있을 경우, 문의주시기 바랍니다.
감사합니다.
그레이프시티 드림