Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Grid: losing the column's DynamicBackColor
Message
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00679377
Message ID:
00682026
Views:
24
Nick:

Thanks for taking time to review my code. For anyone reading this, i was setting all the grid properties in a method called from INIT (and from other methods). Very few properties were set at design time. Nick pointed out that:
* You have to Requery and Refresh the combo after setting the 
* RowSource in code. Otherwise it causes resetting the field 
* value for the first record in the table to 0 as soon as you
* issue .column1.CboProject.BoundTo  = .t., as the CboProject.List
* at that moment is still 0
.column1.CboProject.Requery() && [NN] added
.column1.CboProject.Refresh() && [NN] added
Was finding that the first row's field value being set to zero. Nick's code corrected this. After replacing the one grid with a pageframe that holds 2 grids (one grid per page), I found that the grid highliting would not kick in unless i added the following in the form's INIT (not an issue prior to adding the pageframe):
thisform.pagetime.page1.grdtime.afterrowcolchange()
thisform.pagetime.page2.grdtime.afterrowcolchange()
I recommend his GridHighlighter, very easy to implement. The following code now works:
thisform.pagetime.page1.grdtime.recordsource = "TmpTime"
thisform.pagetime.page2.grdtime.recordsource = "TmpTime"

nDay = 0
WITH THISFORM.pagetime.page1.grdtime

  .column1.Controlsource = "tmptime.prjfk"
  .column1.header1.CAPTION = "Proj # / name"
  .column1.Cboproject.ColumnCount = 2
  .column1.Cboproject.ColumnWidths = "150,0"
	
  * Version 1	 - Original version. Somehow will not show the 
  * value in the combobox when it is an active cell. 
  * However, it keeps the original value in the table and shows
  * it again when another column activates
  *!* 	.column1.CboProject.rowsourcetype = 6  
  *!*	.column1.CboProject.rowsource = "timeproj.prjdesc,prjpk"
  * Version2 - Nick's version. Works properly in all cases
  .column1.CboProject.rowsourcetype = 3  &&  - SQL Statement [NN] 
  .column1.CboProject.rowsource =  "select prjdesc,prjpk from timeproj order by prjdesc into cursor _cCboProject"
  ********	
  * You have to Requiery and Refresh the combo after setting the 
  * RowSource  in code.  Otherwise it causes resetting the field 
  * value for the first record in the table to 0
  * as soon as you issue .column1.CboProject.BoundTo  = .t., as the 
  * CboProject.List at that moment is still 0
  .column1.CboProject.Requery() && [NN] added
  .column1.CboProject.Refresh() && [NN] added
  .column1.CboProject.boundcolumn = 2
  .column1.CboProject.boundto  = .t.
  .column1.WIDTH = 150
  .column2.CboCostCode.ColumnWidths = "55"
  .column2.WIDTH = 50
  .column2.header1.CAPTION = "Cost"
  .column2.controlsource   = "tmptime.costcodefk"	
  .column2.CboCostCode.rowsourcetype = 6	
  .column2.CboCostCode.rowsource = "timecost.costcode"
  .column2.CboCostCode.ColumnCount = 1
	
  * You have to Requery and Refresh the combo after setting the 
  * RowSource in code. Otherwise it causes resetting the field 
  * value for the first record in the table to 0 as soon as you 
  * issue .column1.CboCostCode.BoundTo  = .t., as the 
  * CboCostCode.List at that moment is still 0	
  .column2.CboCostCode.Requery() && [NN] added
  .column2.CboCostCode.Refresh() && [NN] added
  .column2.CboCostCode.boundcolumn = 1
  .column2.CboCostCode.boundto     = .t.
  ***
  .column3.header1.CAPTION = "R or E"
  .column3.WIDTH = 35
  .column3.CboRorE.boundto = .t. 
  * [NN] Here you don't need to Requery/Refresh as the RowSource 
  * is set in the Property Sheet.
  .column3.CboRorE.boundcolumn = 1
  .column3.CboRorE.ColumnWidths = "35"
  .column3.controlsource = "tmptime.rore"

  xDateCntr = 0
	
  nDay = 0
  FOR x = 4 TO 17
    * set the day columns 4-17 WIDTH, CAPTION, and CONTROLSOURCE values
    nDay = nDay + 1
    cWidth = "column"+ALLTRIM(STR(x))+".width"
    .&cWidth = THISFORM.zDayColWidth
    cHeader = "column"+ALLTRIM(STR(x))+".header1.caption"
    cap = ALLTRIM(STR(nDay))
    xDateCntr = xDateCntr + 1
    .&cHeader = "&cap."
    cSource = "column"+ALLTRIM(STR(x))+".controlsource"
    cFie = "tmptime.R"+ALLTRIM(STR(nDay))
    .&cSource  = "&cFie"
    cFormat = "column"+ALLTRIM(STR(x))+".format"
    .&cFormat = "Z"
  ENDFOR

  FOR x = 1 TO 17
    * make day columns 1-17 NOT resizable and NOT movable
    cCol = "column"+ALLTRIM(STR(x))+".resizable"
    .&cCol = .F.
    cCol = "column"+ALLTRIM(STR(x))+".movable"
    .&cCol = .F.
  ENDFOR
  .column18.WIDTH = 67
  .column18.header1.CAPTION = "Month total"
  .column18.CONTROLSOURCE   = "tmptime.rTotal"
  .column18.READONLY = .T.
ENDWITH
>Chris,
>
>Try it this way:
>
>Remove all the code you added to Gridhighlighter1 methods.
>
>Set Gridhighlighter1.lCustomCondition to .t.
>Set Gridhighlighter1.cCustomCondition to BETWEEN(tmptime.projfk,1,10)
>Set Gridhighlighter1.cMultipleRecordsColor to RGB(215,255,215)
>
>Put in Combo.When() method:
>
>l_return = .t.
>IF BETWEEN(tmptime.projfk,1,10)
>  wait window "tmptime.projfk = "+ALLTRIM(STR(tmptime.projfk))
>  l_return = .f.
>ENDIF
>RETURN l_return
>
>
>
>
>>TmpTime is the recordsource. I have tried the code with and without the "SELECT tmptime" line.
>>
>>
>>>Hi Chris,
>>>
>>>Is tmptime your GrdTime.RecordSource?
>>>I may try to reproduce what you have. It might be related to SELECT in your code.
Previous
Reply
Map
View

Click here to load this message in the networking platform