ANW
15 years agoContributor
.NET radPanelBar: how to find and click one of the items??
My applications make use of the Telerik radPanelBar, and I am having some issues trying to click on specific items in that object.
When running the Recorder in TC8.10, it just clicks on coordinates in the radPanelBar object. This is not really what I want, as the bar might change, and the coordinates to my menu item change too.
Now I have managed to locate the actual Item by iteriating through the radPanelBarObj.Items.item until I found one with the correct Caption. But I can't seem to find a Method, that then lets me activate/click on that item to open my tree view.
I have tried with Expand, Select, Focus, PerformClick. But none seem to work.
I have been using the following code to try this out:
function FindradPanelbarItem(radPanelbar: Olevariant; menuItemName: string): OleVariant;
var
count, menuCount : integer;
menuCaption : string;
menuItem : Olevariant;
begin
count := 0;
menuCount := radPanelBar.Items.Count;
repeat
menuItem := radPanelBar.Items.item(count);
menuCaption := menuItem.Caption.OleValue;
inc(count);
until
(menuCaption = menuItemName) OR (count = menuCount -1);
if (menuCaption = menuItemName) then
result := menuItem
else
Log.error('Caption not found',
'Menu item was not found with caption <' + menuItemName + '>');
end;
procedure Test1;
var castorTEST : OleVariant;
var splitContainer : OleVariant;
var radPanelBar : OleVariant;
var menuMobile : OleVariant;
begin
castorTEST := Sys.Process('CastorTEST');
splitContainer := castorTEST.CastorApp.WinFormsObject('toolStripContainer2').WinFormsObject('ToolStripContentPanel', '', 1).splitContainer1;
radPanelBar := splitContainer.WinFormsObject('SplitterPanel', '', 1).navigationPane1.WinFormsObject('radPanelBar1');
// radPanelBar.Click(77, 650);
menuMobile := FindradPanelbarItem(radPanelBar,'Mobiltelefoni');
menuMobile.PerformClick;
end;
Is there any way I can activate the specific item I need to use?? ... or am I forced to use coordinates for it?
When running the Recorder in TC8.10, it just clicks on coordinates in the radPanelBar object. This is not really what I want, as the bar might change, and the coordinates to my menu item change too.
Now I have managed to locate the actual Item by iteriating through the radPanelBarObj.Items.item until I found one with the correct Caption. But I can't seem to find a Method, that then lets me activate/click on that item to open my tree view.
I have tried with Expand, Select, Focus, PerformClick. But none seem to work.
I have been using the following code to try this out:
function FindradPanelbarItem(radPanelbar: Olevariant; menuItemName: string): OleVariant;
var
count, menuCount : integer;
menuCaption : string;
menuItem : Olevariant;
begin
count := 0;
menuCount := radPanelBar.Items.Count;
repeat
menuItem := radPanelBar.Items.item(count);
menuCaption := menuItem.Caption.OleValue;
inc(count);
until
(menuCaption = menuItemName) OR (count = menuCount -1);
if (menuCaption = menuItemName) then
result := menuItem
else
Log.error('Caption not found',
'Menu item was not found with caption <' + menuItemName + '>');
end;
procedure Test1;
var castorTEST : OleVariant;
var splitContainer : OleVariant;
var radPanelBar : OleVariant;
var menuMobile : OleVariant;
begin
castorTEST := Sys.Process('CastorTEST');
splitContainer := castorTEST.CastorApp.WinFormsObject('toolStripContainer2').WinFormsObject('ToolStripContentPanel', '', 1).splitContainer1;
radPanelBar := splitContainer.WinFormsObject('SplitterPanel', '', 1).navigationPane1.WinFormsObject('radPanelBar1');
// radPanelBar.Click(77, 650);
menuMobile := FindradPanelbarItem(radPanelBar,'Mobiltelefoni');
menuMobile.PerformClick;
end;
Is there any way I can activate the specific item I need to use?? ... or am I forced to use coordinates for it?