Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Inconsistant results with dynamiccurrentcontrol
Message
From
25/09/2003 04:25:17
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00832044
Message ID:
00832118
Views:
29
This message has been marked as the solution to the initial question of the thread.
>I have a form with a grid whose first column uses the DynamicCurrentControl property. The grid is not initially tied to anything (no rowsource, no dynamiccurrentcontrol).
>
>The form also has a method called _SwitchView. _SwitchView is responsible for creating a cursor (based on a parameter passed to _SwitchView) and tying that grid to the cursor.
>
>Lastly, I have a button on the form that calls _SwitchView with the parameter of "Inbox".
>
>The form's Init() method makes the exact same call to _SwitchView as the button does:
>
>
>thisform._switchview("Inbox")
>
>
>When you first launch the form, the code in _switchview works beautifully. The cursor is created, the first column is dynamically evaluated and the column uses either an image control or a textbox depending on the value of the first field in the cursor.
>
>However, if I press the button on the form (which makes the exact same call), the cursor is built, the grid displays but the first column uses the textbox control rather than switching between the image or the textbox.
>
>Here is the code in _switchview:
>
>
>this.LockScreen = .T.
>
>DO CASE
>   CASE cBoxName = "Inbox"
>		
>   IF !USED('artiein')
>      USE g:\email\artiein IN 0
>   ENDIF
>		
>   SELECT IIF(fromname = "Rodd Harris","c:\temp\image.bmp","");
>     as attachment, fromemail, subject, received, body, fulltext,;
>     fromname FROM artiein;
>     INTO CURSOR temp
>		
>   USE IN artiein
>		
>   this.grdList.RecordSource = "temp"
>   this.grdList.RecordSourceType = 1
>   this.grdList.ColumnCount = 4
>	
>   this.grdList.column1.ControlSource = "temp.attachment"
>   this.grdList.column1.Sparse = .F.
>   this.grdList.column1.DynamicCurrentControl = ;
>      "iif(EMPTY(temp.attachment),'text1','imgntm1')"
>
>   this.grdList.column2.header1.Caption = "From"
>   this.grdList.column2.ControlSource = "temp.fromemail"
>   this.grdList.column3.ControlSource = "temp.Subject"
>   this.grdList.column4.ControlSource = "temp.received"
>		
>   CASE cBoxName = "Outbox"
>      ...
>ENDCASE
>
>this.LockScreen = .F.
>
>this.grdList.Refresh()
>
>
>Any ideas why the DynamicCurrentControl seems to evaluate properly the first time around but not the next? (incidentally the cursor built is exactly the same in both cases)
>
>Thanks for your help!
>
>Rodd

Rodd,
I think old recordsource is 'temp' too. If you rebuild cursor while it's assigned as a recordsource the grid control's are rebuilt (default textbox replaces your controls). First assign recordsource to an empty string :

this.grdList.RecordSource = ""
* Create cursor
this.grdList.RecordSource = "temp"

PS: From your code I think it'd be easier to use an SQL recordsourcetype and refresh to 'requery'.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform