TreeView control and data window combination control principle

zhaozj2021-02-11  202

In a system implementation, the editing and display of the material list is encountered, and the detailed composition of a product can be displayed in accordance with the tree structure. For example, the product is divided into several large-scale, and there are several devices, components, parts, parts, and the like under each assembly, which may form a very complex tree structure. Moreover, complex lookup, filtration, etc. are required, so it is a very ideal control construction method that combines with the Data Window and Filter, Sort (sort) or the like. In PB, it is possible to satisfy such requirements through the tree and the data window. Even the generic control is used to meet the editing of all tree structure types.

The following describes the main principles: 1. Data window, including each column used to process the tree node TreeViewItem, such as code, name, parent code, hierarchy, sort, other, etc .; 2, when creating data windows, in SQL syntax A computing column (pseudo column): item_handle, used to store the tree handle corresponding to the row; 3, from standard TreeView, establish UserObject, name: PFC_TreeView, establish a function of the control: · uf_init_tree (as_data_store, as_id_col, as_name_col, as_parent_col, as_level_col, as_sort_string) // datastore synchronization · uf_init_Tree (as_data_window, as_id_col, as_name_col, as_parent_col, as_level_col, as_sort_string) // window data synchronization · uf_find_id (string as_id_value) return long // lookup (in accordance with the actual ID Find the data window and return Item_Handle value); · uf_find_name (string as_name_value) return long // accordance name_column to find; · uf_get_all_handle (ref al_handles []) return long // return all handles; · uf_get_current_handle () return long / / Return the current handle; • UF_GET_CURRENT_ITEM () Return TreeViewItem // Returns the current node; • UF_GET_CURRENT_ID () // Returns the ID value of the current node · UF_GET_CURRENT_NAME () // Returns the Label value of the current node · UF_GET_CURRENT_DATA () // Return to the current The Node's DATA value, the ANY type, can be expanded to Structure to store other data · UF_GET_CHILD_HANDLE (REF AL_CHILD_HANDLE []) // Returns all child node handles of the current node · UF_GET_PARENT_HANDLE (Ref al_parent_handle [] / / Returns the parent node handle of the current node until the top level; ... · UF_UPDATE_ITEM (AL_HANDLE) // Update node; • UF_INSERT_ITEM (AL_PARENT_HANDLE, ATVI_ITEM) // Increase node 4, in the application, direct this control directly Put in the window and then call the uf_init_tree () function to initialize; 5, if it is a common tree, write the initialization function in the construct event of the PFC_TreeView, so you can use it directly.

转载请注明原文地址:https://www.9cbs.com/read-3763.html

New Post(0)