Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Re-binding RecordSource to grid, and ControlSources to C
Message
 
To
25/03/2004 07:04:49
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00889474
Message ID:
00889796
Views:
18
The [blank] cursor has to be available to the grid when the Grid's "recordsource" property receives it's assignment.

If the cursor is created at grid init, it may be too late! I think the containers init only fires after all it contains has fired.

In the grid's form's load event:
create cursor curGrid1(field_one c(20),field_etc n(10,2))

In the grid:
Recordsource=curGrid1


>Terry:
>
>I've tried both setting the Grid programmatically (1) at initialization to a dummy Cursor that I've created with CREATE CURSOR statement; and my current implementation (design-time) shown below for Grid properties (2):
>
>BOTH Implementations have same design-time properties for Grid.
>
>LinkMaster (None)
>ReadOnly .F. - False (Default)
>RecordSource (None)
>RecordSourceType 1 - Alias
>RelationalExpr (None)
>
>And, Columns inside the grid:
>
>colDwgnum:
> Bound .F.
> ControlSource (None)
> CurrentControl Text1
> ReadOnly .T.
> Sparse .F.
>colRev:
> Bound .F.
> ControlSource (None)
> CurrentControl Text1
> ReadOnly .T.
> Sparse .F.
>colTitle:
> Bound .F.
> ControlSource (None)
> CurrentControl Text1
> ReadOnly .T.
> Sparse .F.
>colHours:
> Bound .F.
> ControlSource (None)
> CurrentControl Text1
> ReadOnly .T.
> Sparse .F.
>colWrkCtr:
> Bound .F.
> ControlSource (None)
> CurrentControl Text1
> ReadOnly .T.
> Sparse .F.
>colUse:
> Bound .T.
> ControlSource .F.
> CurrentControl Check1
> ReadOnly .F.
> Sparse .F.
>
>
>(1) 1st Implementation:
>
>Grid.Init()
>
>CREATE CURSOR curDrawings (;
> dh_dwgnum C(10) null, dh_rev C(5) null, ;
> dh_stitle C(28) null, td_code C(5) null, ;
> td_mnhrs I null, td_ecd D null, col_use L DEFAULT .F.)
>
>*!* NOTE: There is an add'l textbox field outside the grid
>*!* that comes from the same cursor source.
>
>INSERT INTO curGrdDwgs VALUES(null,null,null,null,null,null,null,null)
>SELECT curGrdDwgs
>GO TOP
> This.RecordSource = "curDrawings"
> This.colDwgnum.ControlSource = "curDrawings.dh_dwgnum"
> This.colRev.ControlSource = "curDrawings.dh_rev"
> This.colTitle.ControlSource = "curDrawings.dh_stitle"
> This.colHours.ControlSource = "curDrawings.td_mnhrs"
> This.colWrkCtr.ControlSource = "curDrawings.td_code"
> This.colUse.ControlSource = "curDrawings.col_use"
> This.Refresh
> Thisform.txtDtEnd.ControlSource = "curDrawings.td_ecd"
> Thisform.txtDtEnd.Refresh
>
>NOTE: (1) executes same code on Event that (2) outlines.
>
>(2) Grid.Init() does nothing.
>
>There are two ComboBoxes on form: cboPcode, and cboDwgTask. The order forced on user, is to select from cboPcode, then cboDwgTask.
>
>User selects item from cboPcode Combobox.
>
>When cboPcode.LostFocus() fires: A SQL Select is executed against this value to see if there are related records on other tables, which will allow Enable of cboDwgTask, and its' population. Form variable p_pcode is set to value selected from cboPcode.
>
>User then selects item from cboDwgTask Combobox.
>
>These items, will be guaranteed to join against [Drawing] records that will populate Grid, and adjoining textbox (note that textbox should show separate Cursor field from Grid column fields for ActiveRow in grid).
>
>On LostFocus from cboDwgTask we need to populate Grid, and adjoining Textbox.
>
>cboDwgTask.LostFocus()
>
>*!* TaskList ID
>THISFORM.p_tlid = INT(VAL(THISFORM.cboDwgTask.Value))
>
>SELECT D.dh_dwgnum as dh_dwgnum, D.dh_rev as dh_rev, ;
> D.dh_stitle as dh_stitle, TD.td_code as td_code, ;
> TD.td_mnhrs as td_mnhrs, TD.td_ecd as td_ecd, .F. as col_use ;
>FROM DD_dwgh D, DD_tskdwgs TD, DD_tasklist L ;
> WHERE L.tl_id = THISFORM.p_tlid ;
> AND L.tl_id = TD.td_tlid ;
> AND D.dh_dcn = TD.td_dcn ;
> ORDER BY dh_dwgnum ;
>INTO CURSOR curDrawings READWRITE
>
>THISFORM.txtDtEnd.Enabled = .T.
>THISFORM.grdDrawings.Enabled = .T.
>THISFORM.grdDrawings.RecordSource = "curDrawings"
>
>THISFORM.grdDrawings.colDwgnum.ControlSource = "curDrawings.dh_dwgnum"
>THISFORM.grdDrawings.colRev.ControlSource = "curDrawings.dh_rev"
>THISFORM.grdDrawings.colTitle.ControlSource = "curDrawings.dh_stitle"
>THISFORM.grdDrawings.colHours.ControlSource = "curDrawings.td_mnhrs"
>THISFORM.grdDrawings.colWrkCtr.ControlSource = "curDrawings.td_code"
>THISFORM.grdDrawings.colUse.ReadOnly = .F.
>THISFORM.grdDrawings.colUse.ControlSource = "curDrawings.col_use"
>
>THISFORM.grdDrawings.colDwgnum.Refresh
>THISFORM.grdDrawings.colRev.Refresh
>THISFORM.grdDrawings.colTitle.Refresh
>THISFORM.grdDrawings.colHours.Refresh
>THISFORM.grdDrawings.colWrkCtr.Refresh
>THISFORM.grdDrawings.colUse.Refresh
>THISFORM.grdDrawings.Refresh
>
>*!* LOCATE TAKES YOU TO TOP OF Cursor for grid hilite of 1st row.
>LOCATE
>THISFORM.txtDtEnd.ReadOnly = .F.
>THISFORM.txtDtEnd.Refresh
>THISFORM.txtDtEnd.ReadOnly = .T.
>
>
>Any ideas on alternate coding, or design-time solution are gratefully
>appreciated, thanks.
>
>Dbk
Imagination is more important than knowledge
Previous
Reply
Map
View

Click here to load this message in the networking platform