Forum Discussion

Aaleena's avatar
Aaleena
New Member
2 years ago

Issue with retrieving text from listbox items in desktop win32 application

Hi All,

I have a listbox object type item in my desktop application , which is in a table structure while trying to retrieve the text in the table i am getting error  "Failed to retrieve text, because the items are owner-drawn.The list box is not of the LBS HASSTRINGS style. More information can be found in the MSDN library. The witem, witemList and wSelectedItems methods will return an empty string " in the wSelectedItems property.Any idea how we can fix this issue 

 

3 Replies

  • rraghvani's avatar
    rraghvani
    Icon for Champion Level 3 rankChampion Level 3

    Do you have a screenshot of the UI control? And a screenshot of the Object Browser together with the properties shown.

    What version of TC are you using?

  • This is occuring for me when trying to access wItem and "Point and fix" doesn't detect the table entries just the whole element. I had to enable textbox detection.

     

    • JDR2500's avatar
      JDR2500
      Frequent Contributor

      Well, I don't have a 100% clear picture of what you're trying to accomplish.  For instance, you haven't provided a screen capture of you list box.  Additionally, is it correct to assume you are trying to click on one of the list items, or are you trying to identify the text of one of them by its position/index in the list?

      I think you may be able to accomplish either of those tasks using the "Items" property for the list box object.  I've had success with that under similar circumstances.  It's at least worth a try.

      Here is an example in VBScript using "Items" and the "Description" property to find the desired list item and click it:

      '-- Find the desired item, "Bob", by looping through all the items.  Once found click on it
        Set o_list = <your list object here>
        i = -1
        For i_item = 0 to o_list.wItemCount - 1
          If o_list.Items.Item(i_item).Description = "Bob" Then
            i = i_item
            o_list.WPFObject("ListBoxItem", "", i+1).Click
            Exit For
          End If
        Next

      You'll have to investigate if the "Items" and "Description" properties are available and will work for you. 

      Good luck, John