Forum Discussion
Bharadwaj
10 years agoContributor
You need to calculate the Cells x,y coordinates using the properties like this,this code is for getting cell coordinates of a flex grid in a desktop application. If your application is a web application then you have similar properties ScreenTop,Top,ScreenLeft,Left etc use them and follow exactly the same below logic.
function GetCellCoordinates(var x:integer,var y:integer;grid:OleVariant,RowIndex:integer,ColIndex:integer,parentObj:OleVariant=nil);
var
page,obj:OleVariant;
cellX,cellY,cellPixRatio : integer;
begin
try
if IsNullNil(parentObj) then
parentObj := grid.Parent;
grid.SetFocus;
grid.Row := RowIndex;
grid.Col := ColIndex;
cellX := grid.CellTop + parentObj.Top;
cellY := grid.CellLeft + parentObj.Left;
//Convert the CellX and CellY into Pixels
cellPixRatio := VarToInt(parentObj.ScaleWidth/parentObj.Width);
x := VarToInt(cellX/cellPixRatio);
y := VarToInt(cellY/cellPixRatio);
Log.Message('Cell : ' + VarToStr(RowIndex) + ',' + VarToStr(ColIndex) +' Cell Width : ' + VarToStr(grid.CellWidth) + ' X Coord : ' + VarToStr(x) + ' Y Coord : ' + VarToStr(y));
except
Log.Error('Exception in GetCellCoordinates ',exceptionmessage);
end
end;