Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
ComboBox Erratic Fatal Error behavior
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00806399
Message ID:
00806413
Vues:
21
Thanks, but I just wanted the 242 line. Is it grid.SetFocus()? Never set focus from Init, it breakes event sequences. Just made grid the first object in tab order.

>Nadya
>
>Here is the code :
>
>
>PARAMETERS p_fldlist,p_headers,p_width,indx1,indx2,indx1name,indx2name,cw1,cw2,cw3,cw4,cw5,p_refresh, p_ndx1,p_ndx2
>
>* PARAMTERS
>*	p_fldlist	= passed field list
>*	p_headers	= field descriptions
>*	p_width		= width of form
>*	indx1		= search field1
>*	indx2		= search field2
>*	indx1name	= search field1 caption
>*	indx2name	= search field2 caption
>*	cw1			= width of column1
>*	cw2			= width of column2
>*	cw3			= width of column3
>*	cw4			= width of column4
>*	cw5			= width of column5
>*	p_refresh	= always refresh selection
>
>* tah - 02/22/2002 per DRS removed this line of code so the lookup will always be grey.  If it is the
>* same color as the other forms it can blend into the calling form.  If it is always grey it stands out
>* from the calling form.
>*!*	thisform.backcolor = mainmenu.background
>
>* Store the column widths and the total of the column widths
>THISFORM.r_fldLengths(6) = 0
>FOR pCnt = 1 TO 5
>	pCW = "cw" + STR(pCnt,1)
>	THISFORM.r_fldLengths(pCnt) = &pCW
>	THISFORM.r_fldLengths(6) = THISFORM.r_fldLengths(6) + &pCW
>ENDFOR
>
>* tah - 03/13/2002 #271 If p_ndx1 or p_ndx2 is not numeric and/or is less than 1 ... set to 1
>IF TYPE("p_ndx1") # "N" OR p_ndx1 < 1
>	p_ndx1 = 1
>ENDIF
>IF TYPE("p_ndx2") # "N" OR p_ndx2 < 1
>	p_ndx2 = 1
>ENDIF
>
>THISFORM.indexcol1 = p_ndx1
>THISFORM.indexcol2 = p_ndx2
>
>THISFORM.r_refresh = p_refresh
>
>THISFORM.OldExact = SET("exact")
>SET EXACT OFF
>
>THISFORM.srchindex1 = ' '
>THISFORM.srchindex2 = ' '
>
>DO CASE
>
>	CASE !EMPTY(indx1) AND !EMPTY(indx2)
>		THISFORM.srchindex1 = indx1
>		THISFORM.srchindex2 = indx2
>		THISFORM.sortby.option1.CAPTION=indx1name
>		THISFORM.sortby.option2.CAPTION=indx2name
>
>		IF jnLookUpOrder = 1
>			SET ORDER TO (indx1)
>		ELSE
>			SET ORDER TO (indx2)
>		ENDIF
>		THISFORM.sortby.VALUE = jnLookUpOrder
>
>		*!*		Set order to (indx1)
>
>	OTHERWISE
>		THISFORM.sortby.option1.VISIBLE=.F.
>		THISFORM.sortby.option2.VISIBLE=.F.
>		THISFORM.lblsort.VISIBLE=.F.
>ENDCASE
>
>* tah - 06/21/00 removed the "go top" to remain at the spot in the file where you are.
>*!*	Go top
>PUSH KEY CLEAR
>* tah - 06/21/00 removed the "on key label esc" so the user can press esc to exit.
>*!*	On KEY LABEL ESC *
>
>THISFORM.WIDTH = p_width
>
>* tah - 07/03/00 reset autocenter after form width is set center the form.
>THISFORM.AUTOCENTER = .T.
>
>PRIVATE ALL LIKE l_*
>DIMENSION THISFORM.r_flds[1]
>
>THISFORM.r_flds = ""
>THISFORM.r_alias = ALIAS()
>IF !EOF()
>	THISFORM.r_oldrec=RECNO()
>ELSE
>	LOCATE
>	IF EOF()
>		* No records in table
>		mainmenu.cemmessagebox('SM-5')
>		* Set public variable .f. so menu items are active
>		plLookUp = .F.
>		*!*			mainmenu.plLookUp = .f.
>		* Exit without displaying the grid
>		RETURN .F.
>	ELSE
>		THISFORM.r_oldrec = RECNO()
>	ENDIF
>ENDIF
>
>* If the table has a field named "FormName"...see if any records are able to be selected.
>nnn = AFIELDS(FieldsArry)
>nnn = ASCAN(FieldsArry,"FORMNAME")
>IF nnn # 0
>	rrr = RECNO()
>	COUNT TO x FOR EMPTY(FormName)
>	GO rrr
>	IF x = 0
>		* No records able to be selected.
>		mainmenu.cemmessagebox("SM-3")
>		* Set public variable .f. so menu items are active
>		plLookUp = .F.
>		*!*			mainmenu.plLookUp = .f.
>		* Exit without displaying the grid
>		RETURN .F.
>	ENDIF
>	THISFORM.r_FormName = .T.
>ENDIF
>
>l_firstchr = 1
>l_lastchr = 1
>l_numfld = 0
>l_fldlen = 0
>DO WHILE l_lastchr <= LEN(p_fldlist)
>	l_numfld = l_numfld+1
>	DIMENSION THISFORM.r_flds[l_numfld]
>	IF AT(",",p_fldlist,l_numfld) > 0
>		l_lastchr = AT(",",p_fldlist,l_numfld)-1
>	ELSE
>		l_lastchr = LEN(p_fldlist)+1
>	ENDIF
>	THISFORM.r_flds[l_numfld] = ;
>		ALLTRIM(SUBSTR(p_fldlist,l_firstchr,l_lastchr-l_firstchr+1))
>
>	IF AT(",",p_fldlist,l_numfld)>0
>		l_firstchr=AT(",",p_fldlist,l_numfld)+1
>	ELSE
>		l_firstchr = LEN(p_fldlist)
>	ENDIF
>
>	l_fldname = THISFORM.r_alias+"."+THISFORM.r_flds[l_numfld]
>	DO CASE
>		CASE TYPE("&l_fldname") = "N"
>			lcsub = ALLTRIM(STR(&l_fldname))
>			l_fldlen = l_fldlen + LEN(lcsub)
>			THISFORM.grdsearch.COLUMNS(l_numfld).REMOVEOBJECT('_editbox1')
>		CASE TYPE("&l_fldname") = "L"
>			lcsub = IIF(&l_fldname,"T","F")
>			l_fldlen = l_fldlen + 1
>			THISFORM.grdsearch.COLUMNS(l_numfld).REMOVEOBJECT('_editbox1')
>		CASE TYPE("&l_fldname") = "C" OR TYPE("&l_fldname") = "M"
>			l_fldlen = l_fldlen + LEN(&l_fldname)
>			THISFORM.grdsearch.COLUMNS(l_numfld).CURRENTCONTROL='_editbox1'
>		CASE TYPE("&l_fldname") = "U"
>			DIMENSION Error_Arry(1)
>			Error_Arry(1) = l_fldname
>			CLEAR TYPEAHEAD
>			mainmenu.cemmessagebox("SM-22", @Error_Arry)
>			RETURN .F.
>		CASE TYPE("&l_fldname") = "D"
>			THISFORM.grdsearch.COLUMNS(l_numfld).REMOVEOBJECT('_editbox1')
>	ENDCASE
>ENDDO
>THISFORM.r_numfld = l_numfld
>THISFORM.r_fldlen = l_fldlen
>
>DIMENSION a_head[1]
>a_head = ""
>l_firstchr = 1
>l_lastchr = 1
>l_numfld = 0
>l_headlen = 0
>DO WHILE l_lastchr <= LEN(p_headers)
>	l_numfld = l_numfld+1
>	DIMENSION a_head[l_numfld]
>	IF AT(",",p_headers,l_numfld)>0
>		l_lastchr=AT(",",p_headers,l_numfld)-1
>	ELSE
>		l_lastchr = LEN(p_headers)+1
>	ENDIF
>	a_head[l_numfld]=ALLTRIM(SUBSTR(p_headers,;
>		l_firstchr,l_lastchr-l_firstchr+1))
>	IF AT(",",p_headers,l_numfld)>0
>		l_firstchr=AT(",",p_headers,l_numfld)+1
>	ELSE
>		l_firstchr = LEN(p_headers)
>	ENDIF
>ENDDO
>
>WITH THISFORM.grdsearch
>	.RECORDSOURCE=THISFORM.r_alias
>	.COLUMNCOUNT = l_numfld
>	.WIDTH = THISFORM.WIDTH
>	.HEIGHT=THISFORM.HEIGHT-60
>ENDWITH
>
>l_grdwidth=THISFORM.grdsearch.WIDTH-30
>FOR l_indx = 1 TO l_numfld
>	*!*		l_col="thisform.grdsearch.column"+;
>	*!*			ltrim(str(l_indx))
>
>	WITH THISFORM.grdsearch.COLUMNS(l_indx)
>		.CONTROLSOURCE=(THISFORM.r_flds[l_indx])
>		l_fldname=THISFORM.r_alias+"."+THISFORM.r_flds[l_indx]
>		DO CASE
>			CASE TYPE("&l_fldname") = "N"
>				lcsub = ALLTRIM(STR(&l_fldname))
>			CASE TYPE("&l_fldname") = "L"
>				lcsub = IIF(&l_fldname,"T","F")
>			CASE TYPE("&l_fldname") = "C"
>				lcsub = &l_fldname
>		ENDCASE
>		mylen = 'cw' + STR(l_indx,1)
>		IF LEN(lcsub) > &mylen
>			LEN(lcsub)
>			*!*				.width=round((len(lcsub)/l_fldlen)*l_grdwidth,0)
>		ELSE
>			.WIDTH=&mylen
>			*!*				.width=round((&mylen/l_fldlen)*l_grdwidth,0)
>		ENDIF
>		.READONLY = .T.
>	ENDWITH
>	*.l_head = l_col+".header1"
>	WITH THISFORM.grdsearch.COLUMNS(l_indx).header1
>		.CAPTION = (a_head[l_indx])
>	ENDWITH
>ENDFOR
>
>THISFORM.CAPTION =  "Search: "
>
>* Scroll down 3 lines so the initial selection is not at the top of the grid.
>FOR x = 1 TO 3
>	THISFORM.grdsearch.DOSCROLL(0)
>ENDFOR
>
>glapprunning = .T.
>THISFORM.grdsearch.SETFOCUS
>
>
>My OS is Windows 2000 and at home is XP in both have the same problem.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform