Forum Discussion

vjjohnson04's avatar
vjjohnson04
Occasional Contributor
14 years ago

Need help accessing a the wpf data grid

Hi, 


Can someone help me with the code to access a wpf data grid and get the count. 


Thanks to all in Advance.


  • irina_lukina's avatar
    irina_lukina
    Super Contributor

    Hi Vikas,


    Have you tried using the following code?



    WPFObject("grid").Items.Count


    Also, there are some helpful links below that will help you get started:

    1. Working With Grids

    This topic describes how to work with grid controls (including WPF grids) in TestComplete.

    2. How to retrieve data from WPF datagrid through TestComplete

    This forum thread contains a similar question, and you can use it to find out some additional information.


    I hope, this information helps :)

  • vjjohnson04's avatar
    vjjohnson04
    Occasional Contributor

    hi,


    thanks for the help. I got the count using the below code.


    Can u enlighten me on using the WPFObect("Grid").items.count as i get an type mismatch error.



    Code:


    sub get_row_count


     i=Aliases.EFLT_EO_UI.HwndSource_MainView.MainView.Grid.mainTabControl.FeatureView.LayoutRoot.ResidenceSearchView.Grid.advanceResultRadGridView.items.count



    end sub
  • irina_lukina's avatar
    irina_lukina
    Super Contributor

    Hi Vikas,


    Sorry for confusing you. The WPFObject method is applied to the window that holds your control (data grid). That is, you should use the following code:



    Obj = Aliases.EFLT_EO_UI.HwndSource_MainView.MainView.Grid.mainTabControl.FeatureView.LayoutRoot.ResidenceSearchView

    Count = Obj.WPFObject("Grid").Items.Count


    For more information on using the WPFObject method, see its description in the TestComplete online help.