Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problem with selecting a checkbox in a grid
Message
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01246162
Message ID:
01246165
Views:
31
This message has been marked as a message which has helped to the initial question of the thread.
I am not familiar with grdsorting class, but I didn't saw anywhere where you add a CheckBox in the Column6. WHat happens if in init eventof the for you put:
WITH thisform.grdfiles.Column6
      .AddObject([Check1],[CheckBox])
      .RemoveObject([Text1])
      .Check1.Visible = .t.
      .ControlSource = [curFiles.lSelected]
      .Sparse        = .f.
ENDWITH






>Hi everybody,
>
>I had a FileSelector form developed earlier with the help of IconBuddy class to show associated icons. The form worked fine.
>
>Now I decided to add a checkbox to my grid to allow multiple files selection.
>
>The problem I noticed is when I move my mouse around and try to check not in the currently highlighted record, the click is not always recognised (in most cases it looks like nothing happened).
>
>I saw similar problems before, but this one seems to be the worse of everything I've seen so far.
>
>Bellow is a class code, may be you can spot my problem or offer some suggestions to fix this misbehavior?
>
>
>**************************************************
>*-- Class:        frm_files_selector
>*-- ParentClass:  form
>*-- BaseClass:    form
>*-- Time Stamp:   08/03/07 01:55:03 PM
>*-- A list of files in the specific directory
>*
>DEFINE CLASS frm_files_selector AS form
>
>
>	Top = 0
>	Left = 0
>	Height = 306
>	Width = 673
>	DoCreate = .T.
>	Caption = "Select File(s) to process"
>	WindowType = 1
>	*-- Sort by name
>	lsortbyname = .F.
>	Name = "frm_files_selector"
>
>	*-- If this property is set to true, it means that select button was pressed
>	lproceed = .F.
>
>
>	ADD OBJECT cmdselect AS commandbutton WITH ;
>		Top = 266, ;
>		Left = 251, ;
>		Height = 24, ;
>		Width = 71, ;
>		Caption = "\<Select", ;
>		TabIndex = 30, ;
>		ZOrderSet = 7, ;
>		Name = "cmdSelect"
>
>
>	ADD OBJECT cmdcancel AS commandbutton WITH ;
>		Top = 265, ;
>		Left = 351, ;
>		Height = 24, ;
>		Width = 71, ;
>		Caption = "\<Cancel", ;
>		TabIndex = 32, ;
>		Name = "cmdCancel"
>
>
>	ADD OBJECT grdfiles AS grdsorting WITH ;
>		ColumnCount = 6, ;
>		Height = 257, ;
>		Left = 3, ;
>		Panel = 1, ;
>		ReadOnly = .F., ;
>		RecordSource = "curFiles", ;
>		Top = 3, ;
>		Width = 667, ;
>		ZOrderSet = 4, ;
>		Name = "grdFiles", ;
>		Column1.FontSize = 8, ;
>		Column1.ColumnOrder = 2, ;
>		Column1.ControlSource = "", ;
>		Column1.Width = 17, ;
>		Column1.ReadOnly = .T., ;
>		Column1.Sparse = .F., ;
>		Column1.Name = "colImage", ;
>		Column2.FontSize = 8, ;
>		Column2.ColumnOrder = 3, ;
>		Column2.ControlSource = "curFiles.cFile_Name", ;
>		Column2.Width = 154, ;
>		Column2.ReadOnly = .T., ;
>		Column2.Name = "colName", ;
>		Column3.FontSize = 8, ;
>		Column3.Alignment = 1, ;
>		Column3.ColumnOrder = 5, ;
>		Column3.ControlSource = "curFiles.cFIle_Size", ;
>		Column3.Width = 108, ;
>		Column3.ReadOnly = .T., ;
>		Column3.InputMask = "XXXXXXXXXX", ;
>		Column3.Name = "colSize", ;
>		Column4.FontSize = 8, ;
>		Column4.ColumnOrder = 6, ;
>		Column4.ControlSource = "curFiles.cFile_Type", ;
>		Column4.Width = 171, ;
>		Column4.ReadOnly = .T., ;
>		Column4.Name = "colType", ;
>		Column5.FontSize = 8, ;
>		Column5.ColumnOrder = 4, ;
>		Column5.ControlSource = "curFiles.tLast_Modified", ;
>		Column5.Width = 170, ;
>		Column5.ReadOnly = .F., ;
>		Column5.Name = "colLastModified", ;
>		Column6.ColumnOrder = 1, ;
>		Column6.ControlSource = "curFiles.lSelected", ;
>		Column6.Width = 20, ;
>		Column6.ReadOnly = .F., ;
>		Column6.Sparse = .F., ;
>		Column6.Name = "colChecked"
>
>
>	ADD OBJECT frm_files_selector.grdfiles.colimage.header1 AS header WITH ;
>		FontSize = 8, ;
>		Caption = "*", ;
>		Name = "Header1"
>
>
>	ADD OBJECT frm_files_selector.grdfiles.colimage.fileicon AS image WITH ;
>		Height = 104, ;
>		Left = 12, ;
>		Top = 23, ;
>		Width = 300, ;
>		Name = "FileIcon"
>
>
>	ADD OBJECT frm_files_selector.grdfiles.colname.header1 AS header WITH ;
>		FontSize = 8, ;
>		Caption = "Name", ;
>		Name = "Header1"
>
>
>	ADD OBJECT frm_files_selector.grdfiles.colname.cgridtextbox1 AS cgridtextbox WITH ;
>		FontSize = 8, ;
>		ReadOnly = .T., ;
>		SelectedBackColor = RGB(0,0,255), ;
>		Name = "Cgridtextbox1"
>
>
>	ADD OBJECT frm_files_selector.grdfiles.colsize.header1 AS header WITH ;
>		FontSize = 8, ;
>		Alignment = 1, ;
>		Caption = "Size    ", ;
>		Name = "Header1"
>
>
>	ADD OBJECT frm_files_selector.grdfiles.colsize.cgridtextbox1 AS cgridtextbox WITH ;
>		FontSize = 8, ;
>		Alignment = 1, ;
>		ReadOnly = .T., ;
>		SelectedBackColor = RGB(0,0,255), ;
>		Name = "Cgridtextbox1"
>
>
>	ADD OBJECT frm_files_selector.grdfiles.coltype.header1 AS header WITH ;
>		FontSize = 8, ;
>		Caption = "Type", ;
>		Name = "Header1"
>
>
>	ADD OBJECT frm_files_selector.grdfiles.coltype.cgridtextbox1 AS cgridtextbox WITH ;
>		FontSize = 8, ;
>		ReadOnly = .T., ;
>		SelectedBackColor = RGB(0,0,255), ;
>		Name = "Cgridtextbox1"
>
>
>	ADD OBJECT frm_files_selector.grdfiles.collastmodified.header1 AS header WITH ;
>		FontSize = 8, ;
>		Caption = "Last Modified", ;
>		Name = "Header1"
>
>
>	ADD OBJECT frm_files_selector.grdfiles.collastmodified.cgridtextbox1 AS cgridtextbox WITH ;
>		FontSize = 8, ;
>		ReadOnly = .F., ;
>		SelectedBackColor = RGB(0,0,255), ;
>		Name = "Cgridtextbox1"
>
>
>	ADD OBJECT frm_files_selector.grdfiles.colchecked.header1 AS header WITH ;
>		FontName = "Symbol", ;
>		FontSize = 12, ;
>		Caption = "Ö", ;
>		Name = "Header1"
>
>
>	ADD OBJECT frm_files_selector.grdfiles.colchecked.check1 AS checkbox WITH ;
>		Top = 20, ;
>		Left = 11, ;
>		Height = 17, ;
>		Width = 60, ;
>		Caption = "", ;
>		ReadOnly = .F., ;
>		Name = "Check1"
>
>
>	PROCEDURE Load
>		IF DODEFAULT()
>		   create cursor curFiles(cFile_Name c(100), nFile_Size n(10), ;
>		                          cFile_Type c(100), tLast_Modified t, ;
>		                          cIcon_File C(100), cFile_Size C(15), lSelected L)
>		
>		   INDEX on UPPER(cFile_Name) TAG cFile_Name
>		   INDEX on UPPER(cFile_Type) TAG cType additive
>		   INDEX on cFile_Size TAG cSize additive
>		   INDEX on tLast_Modified TAG tDate additive
>		   INDEX ON lSelected TAG lSelected additive
>		ENDIF
>	ENDPROC
>
>
>	PROCEDURE Init
>		lparameters tcDirectory, tcFileExt, tcFilterExpr, tlSortByName
>
>		local lcFileType, lcIconFile, ;
>			loIconBuddy, lcCondition, llAddFile, ;
>			lcFileName, lnI, lnFiles, ;
>			llIconBuddy, lcDir, lnPos, lnK, lcFileExt, lnExts
>
>		local array laFiles[1], laExtUsed[1,3], laExt[1]
>		if empty(m.tcDirectory)
>			lcDir = getdir()
>			if empty(m.lcDir)
>				return .f.
>			endif
>		else
>			lcDir = addbs(m.tcDirectory)
>		endif
>		this.caption = this.caption + ' from ' + m.lcDir
>
>		tcFileExt = lower(evl(m.tcFileExt,""))
>		lnExts = alines(laExt, m.tcFileExt, .t., ',')
>		tcFilterExpr = evl(m.tcFilterExpr,"")
>
>		lnFiles = adir(laFiles, m.lcDir + "*." + ;
>			iif(m.lnExts > 1 or empty(m.tcFileExt), "*", m.tcFileExt),"HS",1)
>
>		if m.lnFiles = 0
>			=ErrorMsg("No files found in " + m.tcDirectory)
>			return .f.
>		endif
>		lnK = 0
>		store .f. to llAddFile, llIconBuddy
>
>		for lnI = 1 to m.lnFiles
>			lcFileExt = lower(justext(laFiles[m.lnI,1])) && File's extension
>			if (empty(m.tcFileExt) or ;
>					ascan(laExt, m.lcFileExt) > 0) ;
>					and not ;
>					inlist(m.lcFileExt,"exe","dll","ico")
>
>				lcFile = m.lcDir + laFiles[m.lnI,1]
>
>				lcFileName = juststem(m.lcFile)
>
>				if not empty(m.tcFilterExpr)
>					lcCondition = strtran(m.tcFilterExpr, ;
>						"##FILENAME##","lcFileName")
>		* Evaluate the filter condition
>					if evaluate(m.lcCondition)
>						llAddFile = .t.
>					endif
>				else
>					llAddFile = .t.
>				endif
>
>				if m.llAddFile
>					if not m.llIconBuddy
>						thisform.newobject("oIconBuddy", ;
>							"IconBuddy", "IconBuddy.vcx")
>						llIconBuddy = .t.
>					endif
>					lnPos = iif(m.lnK = 0, 0, ;
>						ascan(laExtUsed,upper(justext(m.lcFile)),1,-1,1, 14))
>					if m.lnPos > 0
>						lcIconFile = laExtUsed[m.lnPos, 2]
>						lcFileType = laExtUsed[m.lnPos, 3]
>					else
>		** Create bitmaps and not icons
>						thisform.oIconBuddy.CreateTmpIcons(m.lcFile,.f.,.t.)
>		** Get the small picture
>						lcIconFile = ;
>							thisform.oIconBuddy.GetTMPIconFileName( ;
>							lower(justext(m.lcFile)),.f.,.t.)
>						lcFileType = thisform.oIconBuddy.cFileType
>						if not empty(m.lcFileType)
>							lnK = m.lnK + 1
>							dimension laExtUsed[m.lnK, 3]
>							laExtUsed[m.lnK,1] = upper(justext(m.lcFile))
>							laExtUsed[m.lnK, 2] = m.lcIconFile
>							laExtUsed[m.lnK, 3] = m.lcFileType
>						endif
>					endif
>
>					insert into curFiles values ;
>						(justfname(m.lcFile), laFiles[m.lnI,2], ;
>						m.lcFileType, ;
>						ctot(dtoc(laFiles[m.lnI,3]) + ;
>						" " + laFiles[m.lnI,4]), ;
>						m.lcIconFile, ;
>						alltrim(str(ceiling(laFiles[m.lnI,2]/1024))) + " KB", .f. )
>				endif
>				llAddFile = .f.
>			endif
>		endfor
>
>		if reccount('curFiles') = 0
>			=ErrorMsg("The directory " + m.lcDir + ;
>				" does not contain files")
>			return .f.
>		endif
>
>		if not dodefault()
>			return .f.
>		endif
>
>		thisform.lSortByName = m.tlSortByName
>		thisform.grdFiles.colImage.dynamicfontshadow = ;
>			"thisform.grdFiles.colImage.Refresh()"
>	ENDPROC
>
>
>	PROCEDURE Activate
>		dodefault()
>		with thisform.grdFiles
>			if thisform.lSortByName
>				.colName.Header1.picture = 'upArrow.bmp'
>				.oLastSorted = .colName.Header1
>				set order to cFile_Name
>			else
>				.colLastModified.Header1.picture = 'downArrow.bmp'
>				.oLastSorted = .colLastModified.Header1
>				set order to tDate descending
>			endif
>				go top in curFiles
>				.setfocus()
>		endwith
>	ENDPROC
>
>
>	PROCEDURE cmdselect.Click
>		thisform.lProceed = .t.
>		thisform.Hide()
>	ENDPROC
>
>
>	PROCEDURE cmdcancel.Click
>		thisform.Hide()
>	ENDPROC
>
>
>	PROCEDURE grdfiles.colImage.Refresh
>		NODEFAULT
>		this.FileIcon.Picture = curFiles.cIcon_File
>	ENDPROC
>
>
>ENDDEFINE
>*
>*-- EndDefine: frm_files_selector
>**************************************************
>
>
>Thanks a lot in advance.
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform