sudhir_optima
13 years agoContributor
How to Drag a certain field into the middle of the grid.
We want to drop a Field( One of our object) by dragging it to grid. In Our Form there are few such grids present. But we want to Drop it on certain grid. Which in our application is Active ( By just clicking it get Active) And the Unique property for this is only a Index which chnaged to 1 when any grid is Active.
Please see the attached grid views. Here the Active grid is disaplayd as Selected.
We want to drop a field ( Id,product,quantity) from Left side to the selected grid. We searched and does not found any Uique property for this Active grid.
Please see the object property for one of grid.
Here Winformsobject("gridcontrool") is the grid where we want to drop a field.
But we found that Index of Parent object of one of such grid is changing, which is always 1.
So we have written following function to select the field and drop it to the active grid.
But it is not dropping it into the grid, rather it is dropping elsewhere. Can any one let me know where is the problem.
Function dragfield(itemPath)
{
var flag=0;
Sys.Process("QBIS").Refresh();
var PropNames, PropValues;
PropNames = new Array("Name");
PropValues = new Array("WinFormsObject(\"xtraScrollableControl\")");
for(i=1;i<=5;i++)
{
if(Sys.Process("QBIS").WinFormsObject("MainMirandaConsole").WinFormsObject("MdiClient", "").Find(PropNames, PropValues, 1000, true).WinFormsObject("QuestPanel", "", i).Exists)
{
if(Sys.Process("QBIS").WinFormsObject("MainMirandaConsole").WinFormsObject("MdiClient", "").Find(PropNames, PropValues, 1000, true).WinFormsObject("QuestPanel", "", i).Index==1)
{
var grid =Sys.Process("QBIS").WinFormsObject("MainMirandaConsole").WinFormsObject("MdiClient", "").Find(PropNames, PropValues, 1000, true).WinFormsObject("QuestPanel", "", i).WinFormsObject("DimensionTableNewUC").WinFormsObject("gridControl");
break;
}
}
}
var STX = grid.ScreenLeft;
var SLY = grid.ScreenTop;
Log.Message(STX);
Log.Message(SLY);
var gridTop = STX;
var gridLeft = SLY;
Aliases.QBIS.MainMirandaConsole.Activate();
PropNames = new Array("Name","VisibleOnScreen");
PropValues = new Array("WinFormsObject(\"tvFields\")",true);
ds = Aliases.QBIS.MainMirandaConsole.MdiClient.Find(PropNames, PropValues, 1000, true);
ds.ClickItem(itemPath,0);
var node = ds.SelectedNode;
var nPnt = ds.WindowToScreen(node.Bounds.X,node.Bounds.Y);
var dropX = gridLeft - (nPnt.X);
var dropY = gridTop - (nPnt.Y);
Log.Message(dropX);
Log.Message(dropY);
ds.Drag(node.Bounds.X+5,node.Bounds.Y+5,dropX,dropY);
}
Please see the attached grid views. Here the Active grid is disaplayd as Selected.
We want to drop a field ( Id,product,quantity) from Left side to the selected grid. We searched and does not found any Uique property for this Active grid.
Please see the object property for one of grid.
Here Winformsobject("gridcontrool") is the grid where we want to drop a field.
But we found that Index of Parent object of one of such grid is changing, which is always 1.
So we have written following function to select the field and drop it to the active grid.
But it is not dropping it into the grid, rather it is dropping elsewhere. Can any one let me know where is the problem.
Function dragfield(itemPath)
{
var flag=0;
Sys.Process("QBIS").Refresh();
var PropNames, PropValues;
PropNames = new Array("Name");
PropValues = new Array("WinFormsObject(\"xtraScrollableControl\")");
for(i=1;i<=5;i++)
{
if(Sys.Process("QBIS").WinFormsObject("MainMirandaConsole").WinFormsObject("MdiClient", "").Find(PropNames, PropValues, 1000, true).WinFormsObject("QuestPanel", "", i).Exists)
{
if(Sys.Process("QBIS").WinFormsObject("MainMirandaConsole").WinFormsObject("MdiClient", "").Find(PropNames, PropValues, 1000, true).WinFormsObject("QuestPanel", "", i).Index==1)
{
var grid =Sys.Process("QBIS").WinFormsObject("MainMirandaConsole").WinFormsObject("MdiClient", "").Find(PropNames, PropValues, 1000, true).WinFormsObject("QuestPanel", "", i).WinFormsObject("DimensionTableNewUC").WinFormsObject("gridControl");
break;
}
}
}
var STX = grid.ScreenLeft;
var SLY = grid.ScreenTop;
Log.Message(STX);
Log.Message(SLY);
var gridTop = STX;
var gridLeft = SLY;
Aliases.QBIS.MainMirandaConsole.Activate();
PropNames = new Array("Name","VisibleOnScreen");
PropValues = new Array("WinFormsObject(\"tvFields\")",true);
ds = Aliases.QBIS.MainMirandaConsole.MdiClient.Find(PropNames, PropValues, 1000, true);
ds.ClickItem(itemPath,0);
var node = ds.SelectedNode;
var nPnt = ds.WindowToScreen(node.Bounds.X,node.Bounds.Y);
var dropX = gridLeft - (nPnt.X);
var dropY = gridTop - (nPnt.Y);
Log.Message(dropX);
Log.Message(dropY);
ds.Drag(node.Bounds.X+5,node.Bounds.Y+5,dropX,dropY);
}