In grids and tree parts, it is often necessary to find a row of data in a grid or tree based on a field value or a key value, and to locate the focus, how do you implement such a function? 1, grid parts find positioning:
In the grid part, we can loop through the number of rows displayed, get the values to compare with the lookup values, and the code is as follows:
For I=1 to mesh part 1. Gridview.rowcount If CStr (mesh Part 1. Getfieldvaluebyrowhandle (i-1, "name")) = "Zhang San" then grid Part 1. Focusedrowhandle=i-1 End IfNext
You can also use the Setfocusrowbycolumnvalue method.
Grid Part 1. Setfocusrowbycolumnvalue ("name", "Zhang San")
2, in the tree-type parts, you can use Setfocusnodebycolumnvalue or setfocusnodebykeyvalue to find the node according to the field value or keyword, respectively:
Tree-type Part 1. Setfocusnodebycolumnvalue ("name", "Zhang San")
Based on key values:
Tree-type Part 1. Setfocusnodebykeyvalue ("Key value ID")
> Note: The key value ID is the value of the key Value field set in the tree part property, which forms the tree with the ancestor ID.
above is the method of locating the focus line based on the data of the grid part and the tree part.
Original address: http://bbs.delit.cn/thread-282-1-1.html
Reprint please specify the source:
Author: metric Technology http://www.delit.cn
Grid parts and tree parts find and position focus