Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Dynamic Grids
Message
 
 
To
11/04/2002 11:16:11
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00643772
Message ID:
00643783
Views:
7
>I am needing to build a module to a larger project that needs to build a dynamic grid to use as an input screen based on the data from another table. The grid will change depending on the type of information needed to be input. The table will hold table names, field names, font names, field sizes, record type, captions and what ever else is required. I will query this table to gather together all the items required to build a grid based on the chosen record type. How do I build the grid from this data?
>
>Thanks in advance for any help or ideas.
>Ron

Here is the piece of code my colleague is using:
	select distinct cfldname,colHead as clabel, colwidth, readonlyf ;
		from browflds ;
		where browflds.cedittype= .editType ;
		order by nOrder into array aflds
	nNumflds=_tally
	select browflds
	use
	select bldmstr
	.bldmstrPF1.page1.BldMstrGrid.columncount=nNumflds  && Set the number of columns
	.bldmstrPF1.page1.BldMstrGrid.recordsourcetype = 1      &&  NN 03/25/02
	.bldmstrPF1.page1.BldMstrGrid.recordsource = 'BldMstr'  &&  NN 03/25/02
	for i=1 to nNumflds
*--  the next 4 lines use --columns(i)-- instead of macro  &thiscol
*		thiscol='column'+ALLTRIM(STR(i))					 &&  NN 03/25/02
		.bldmstrPF1.page1.BldMstrGrid.columns(i).header1.caption=aflds(i,2)    &&  NN 03/25/02
		.bldmstrPF1.page1.BldMstrGrid.columns(i).controlsource='bldmstr.'+alltrim(aflds(i,1))
*	thefldnum=ASCAN(BMflds,UPPER(ALLTRIM(aflds(i,1))))   && find the index of the field
		.bldmstrPF1.page1.BldMstrGrid.columns(i).width= aflds(i,3)

* Note - we are using pixels here - the foxels results were not good.
*!*			IF thefldnum<>0
*!*				*.bldmstrpf1.page1.BldMstrGrid.&thiscol..WIDTH=BMflds(thefldnum/16+1,3)
*!*				.bldmstrPF1.page1.BldMstrGrid.&thiscol..WIDTH=((BMflds(thefldnum/16+1,3)*16)/2)		&& 30
*!*				IF BMflds(thefldnum/16+1,3)<LEN(ALLTRIM(aflds(i,2)))
*!*					.bldmstrPF1.page1.BldMstrGrid.&thiscol..WIDTH=LEN(ALLTRIM(aflds(i,2)))*8
*!*				ENDIF
*!*				IF  BMflds(thefldnum/16+1,2) ='I'  && Integer
*!*					.bldmstrPF1.page1.BldMstrGrid.&thiscol..WIDTH=7*10	  &&& set to 7 places
*!*				ENDIF
*!*			ENDIF

		.bldmstrPF1.page1.BldMstrGrid.columns(i).alignment=3
*		.bldmstrPF1.page1.BldMstrGrid.columns(i).readonly=aflds(i,4)  && NSL 1/7/02  Add the readonly property
		.bldmstrPF1.page1.BldMstrGrid.columns(i).readonly=iif(LEditType= "VIEW",.t.,aflds(i,4))
	endfor
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform