Forum Discussion

Jimbo's avatar
Jimbo
Occasional Contributor
9 years ago

Which icon is displayed in datagridview?

Okay, so I have an application which displays various icons depending on the state of the entries in a .NET "DataGridView". I need to verify that the correct icons are displayed.

 

How would one go about this in TestComplete? I've tried various approaches using the scripting language (which is the part of TestComplete I'm most familiar with), but I've been unable to find a way to tell which icon is showing.

 

I've created an example application which displays the same 30 lines everytime you start it up, but the icons are randomized (this is the challenge).

 

So let's say my task is to tell which icon is being displayed at line #10 ... how would I do this in TestComplete? Is scripting even the right way to go?

  • OK.

     

    I think I have a viable property (Field) you can use.

     

    The grid is zero indexed (you show Row 1, Row 2, Row 3 etc in your sample .... they are actually Row 0, Row 1, Row 2) which may confuse some.

     

    But it looks like the - ["nativeImage"] - value (which is a "Field" rather than a "Property") contains a number directly linked to the image displayed.

     

    Full ref to it being:

     

    NameMapping["Sys"]["Process"]("IconDatagrid")["WinFormsObject"]("FormMain")["WinFormsObject"]("dataGridViewExample")["wValue"](<ROW NUMBER>, "Pick this")["nativeImage"]

     

    Which returns:

     

    75768992 row 0
    75763416 row 1
    75768992 row 2
    75768992 row 3
    75763416 row 4
    75763416 row 5
    75768992 row 6

    and so on ....

     

    ... which ties in perfectly with how the images vary.

     

    So 75768992 is your white image. And 75763416 is your red one.

     

    A lookup table for them would seem sensible to make things a little more meaningful.

  • I am not from SB staff but I would do that by finding some kind of unique property that distinguishes these two icons.

     

    • Colin_McCrae's avatar
      Colin_McCrae
      Community Hero

      OK.

       

      I think I have a viable property (Field) you can use.

       

      The grid is zero indexed (you show Row 1, Row 2, Row 3 etc in your sample .... they are actually Row 0, Row 1, Row 2) which may confuse some.

       

      But it looks like the - ["nativeImage"] - value (which is a "Field" rather than a "Property") contains a number directly linked to the image displayed.

       

      Full ref to it being:

       

      NameMapping["Sys"]["Process"]("IconDatagrid")["WinFormsObject"]("FormMain")["WinFormsObject"]("dataGridViewExample")["wValue"](<ROW NUMBER>, "Pick this")["nativeImage"]

       

      Which returns:

       

      75768992 row 0
      75763416 row 1
      75768992 row 2
      75768992 row 3
      75763416 row 4
      75763416 row 5
      75768992 row 6

      and so on ....

       

      ... which ties in perfectly with how the images vary.

       

      So 75768992 is your white image. And 75763416 is your red one.

       

      A lookup table for them would seem sensible to make things a little more meaningful.

      • Jimbo's avatar
        Jimbo
        Occasional Contributor

        Wow, that works!

        I just hope those odd numbers don't change when we recompile the application.

         

        Thanks a lot.