【问题标题】:How to access a second column of a SAP GuiTree Element?如何访问 SAP GuiTree 元素的第二列?
【发布时间】:2017-07-05 08:11:33
【问题描述】:

在我们的 SAP 系统中,我们经常通过 SAP GUI 脚本 API 自动化 GuiTree 控件。在左栏中,有一个描述。在第二列中,有一个包含工具提示的图标。

通过这段代码,我可以读取每个节点的文本:

        /*ID is the SAPFEWSELib.GuiComponent.Id of the SAPFEWSELib.GuiTree; SAPWindow is the mainwindow 
        of SAP of type SAPFEWSELib.GuiMainWindow*/
        SAPFEWSELib.GuiTree GT = (SAPFEWSELib.GuiTree)SAPWindow.FindById(ID);
        foreach (string key in GT.GetAllNodeKeys())
        {
            System.Console.WriteLine("Key " + key + " contains " + GT.GetNodeTextByKey(key));
        }

是否也可以访问第二列?

【问题讨论】:

  • 什么是“锄头”?我不确定我是否对 Urban Dictionary 提供的解释感到满意...
  • 谢谢你,这让我离解决问题更近了...
  • 我喜欢这样的城市谈话和这样的城市帮助:)

标签: c# api sap-gui


【解决方案1】:

好的,我找到了,是GetItemText(key, "1")方法,其中key是节点ID,1是第一列的列索引。

如果该项目被选中,该图标有一个工具提示。

System.Collection.Generic.List<System.Collection.Generic.KeyValuePair<string, bool>> MyList = new System.Collection.Generic.List<System.Collection.Generic.KeyValuePair<string, bool>>();
string NodeText = string.Empty;
bool = TextExist = false;
SAPFEWSELib.GuiTree GT = (SAPFEWSELib.GuiTree)SAPWindow.FindById(ID);
foreach(string key in GT.GetAllNodeKeys()){
     NodeText = GT.GetItemText(key, "1"); //1 is the column index, starts with 1
     if(GT.GetItemText(key, "2").Length > 0){TextExist = true;}else{TextExist = false;}
     MyList.Add(new System.Collection.Generic.KeyValuePair(NodeText, TextExist);   
}

我希望这对其他开发者有所帮助。

【讨论】:

  • 您可以在GuiTree 对象here 的成员上找到官方SAP 文档。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-12-05
  • 2021-08-07
  • 2019-11-26
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多