Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Retrieve.NET datagrid cell value font color
#1
Hi Gintaras!

I have a .NET DataGrid with several columns and rows. I can iterate through the columns and cells to get a value. but I cannot get the cell value font color.
I am using the function you provided in this thread... Not able to find datagrid row or cell not displayed on screen

I need to make sure I select the one that has blue forecolor (the first in this example) since there could be multiple of the same values... the second one has black as the font color. here's a screen shot... Sorry I have to blur out some of the details.


Attached Files Image(s)
   
#2
Function FindElmWithColor.
The example script finds the selected item in a folder window.

Code:
Copy      Help
var w1 = wnd.find(1, "Test - File Explorer", "CabinetWClass");
w1.Activate();
var list = w1.Elm["LIST", "Items View", "class=DirectUIHWND"].Find(1);
var a = list.Elm["LISTITEM"].FindAll();

int i = C.FindElmWithColor(a, list, 0xCDE8FF);
if (i < 0) { print.it("not found"); return; }
print.it(i, a[i]);

class C {
    /// <summary>
    ///
In elm array finds elm that contains given color or image.
    /// </summary>
    ///
<param name="a"></param>
    ///
<param name="area">wnd, elm or RECT that contains all elms.</param>
    ///
<param name="color">Color or image.</param>
    ///
<returns>0-based index, or -1 if not found.</returns>
    ///
<remarks>
    ///
Most parameters are the same as with <see cref="uiimage.find"/>.
    /// </remarks>
    public static int FindElmWithColor(elm[] a, IFArea area, IFImage color, IFFlags flags = IFFlags.WindowDC, int diff = 0) {
        //in area find pixel with color. To create code can be used tool "Find image".
        var im1 = uiimage.find(area, color, flags, diff);
        if (im1 == null) return -1; //color not found
        var rect = im1.RectInScreen;
        
        //in array find elm whose rectangle contains rect
        for (int i = 0; i < a.Length; i++) {
            if (a[i].Rect.Contains(rect)) return i;
        }

        
        return -1;
    }
}
#3
Thank you for the assistance.
It looks like it did not find the desired item. Here's how the UI finder detects it, on this example it's the third item...

Thanks for the assistance.


Attached Files Image(s)
       


Forum Jump:


Users browsing this thread: 2 Guest(s)