Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Inconsistant results with dynamiccurrentcontrol
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Inconsistant results with dynamiccurrentcontrol
Miscellaneous
Thread ID:
00832044
Message ID:
00832044
Views:
47
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
Next
Reply
Map
View

Click here to load this message in the networking platform