tailieunhanh - 1001 Things You Wanted To Know About Visual FoxPro phần 5
Visual Foxpro là sản phẩm của hãng Microsoft, được kế thừa từ Foxpro for Windows, là một trong những công cụ tiện lợi để giải quyết các bài toán trong lĩnh vực quản lý cho những người chuyên nghiệp và không chuyên nghiệp. | 174 1001 Things You Always Wanted to Know About Visual FoxPro which you want to display a fully populated grid where the last available record is displayed as the last line of the grid. This can be done but it is not a trivial exercise. At first you may think Oh this is a piece of cake All I have to do is something like this WITH This GO BOTTOM IN .Recordsource SKIP - Number of rows - 1 IN .RecordSource .setFocus ENDWITH But if you actually test this approach you will quickly discover that it doesn t perform correctly. Even though the grid is positioned on the correct record this record is in the middle of the page and you must use the PAGE DOWN key to see the last record. If this is a common requirement for your grids this sample code in the Init method of is generic and can easily be put in a custom method of your grid class LOCAL lnKey lnMaxRows lcKeyField Make sure procedure file is loaded SET PROCEDURE TO ADDITIVE Display the last page of the grid when the form instantiates IF DODEFAULT WITH Calculate the maximum number of rows per grid page lnMaxRows INT .Height - .HeaderHeight - IIF INLIST .ScrollBars 1 3 SYsMeTRIC 8 0 .RowHeight Get the name of the primary key field in the grid s RecordSource GetPKFieldName is a function defined in the procedure file for this Chapter lcKeyField GetPKFieldName .RecordSource Get the primary or candidate key of the first record to be displayed on the last page of the grid since the goal is to have the grid filled when the form opens GO BOTTOM IN .RecordSource SKIP - lnMaxRows - 1 IN .RecordSource Save the primary or candidate key of this record if it has one IF EMPTY lcKeyField lnKey EVAL .RecordSource . lcKeyField GO BOTTOM IN .RecordSource .Refresh Scroll up one record until we are on the one we want DO WHILE .T. .ActivateCell 1 1 IF EVAL .RecordSource . lcKeyField lnKey EXIT ELSE .DoScroll 0 ENDIF ENDDO Chapter 6 Grids The Misunderstood Controls 175 ENDIF ENDWITH ENDIF .
đang nạp các trang xem trước