Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Stefan Wuebbe
  Where is Stefan Wuebbe?
 Hamburg
 Germany
 Stefan Wuebbe
 To: Ellen Solomon
  Where is Ellen Solomon?
 Bet Shemesh
 Israel
 Ellen Solomon
 Tags
Subject: RE: display problems w/ combo box in grid
Thread ID: 393832 Message ID: 393834 # Views: 49 # Ratings: 3
Version: Visual FoxPro 9 Category: Grids
Date: Tuesday, December 24, 2013 1:06:22 PM         
   


> Hi!
>
> I have a combo box within a grid. The column is set to sparse = F.
>
> The combo box RowSource is a table alias with columns (Desc c(20), Code n(4))
> bound column = 2
> bound to = t
> column widths = 150,0
> column count = 2
> format = !
>
> The description displays great, and with BoundTo = T the ControlSource gets the right value. Everything works great, except one thing: when a cell is not dropped down but has focus it is blank.
>
> I tried to change the column to Sparse = T but then it only shows the description when it has focus, otherwise it shows the numeric setting.
>
> Any suggestions?
>
> Thanks,
> Ellen


Hi Ellen,

As far as I remember, the solution can depend on Service Pack / Hotfix level, where either using a different RowSourcetype can help, as in the sample pasted below with IK_FIX = .F., or Set Decimals To o and Set Fixed On (with IK_FIX = .T. in the sample).



hth
-Stefan



#define IK_FIX	.f.

* combo_in_grid.prg
LOCAL oForm
#if IK_FIX
SET DECIMALS TO 0
SET FIXED ON
#else
SET DECIMALS TO
SET FIXED OFF
#endif

oForm = CREATEOBJECT('TestForm')
oForm.Show(1)
RETURN

DEFINE CLASS TestForm as Form
AutoCenter = .T.
PROCEDURE Load
	LOCAL i
	CREATE CURSOR table1 (table2ID I)
	FOR i = 1 TO 10
		INSERT INTO table1 VALUES (i)
	ENDFOR
	GO top
	CREATE CURSOR table2 (table2ID I, cData C(10))
	FOR i = 1 TO 10
		INSERT INTO table2 VALUES (i, 'Data'+TRANSFORM(i))
	ENDFOR
ENDPROC

ADD OBJECT Grid1 as Grid WITH ;
	Top = 5, Left = 5, ;
	RowHeight = 25, ;
	RecordSource = 'table1'
PROCEDURE Grid1.Init
	WITH This
		.ColumnCount = 3
		.SetAll('ControlSource','table1.table2ID','Column')
		WITH .Column2
			.Header1.Caption = "RST 5"
			.AddObject('TestCombo','ComboRST5')
			.TestCombo.Visible = .T.
			.CurrentControl = 'TestCombo'
			.Sparse = .F.
		ENDWITH
		WITH .Column3
			.Header1.Caption = "RST 2"
			.AddObject('TestCombo','ComboRST2')
			.TestCombo.Visible = .T.
			.CurrentControl = 'TestCombo'
			.Sparse = .F.
		ENDWITH
	ENDWITH
ENDPROC 

ENDDEFINE

DEFINE CLASS ComboRST2 as ComboBox
	RowSourceType = 2
	BoundColumn = 2
	BoundTo = .T.
	RowSource = 'table2.cData,table2ID'
ENDDEFINE
DEFINE CLASS ComboRST5 as ComboBox
	DIMENSION aRowsource[1]
	RowSourceType = 5
	BoundColumn = 2
	BoundTo = .T.
	RowSource = 'This.aRowsource'

	PROCEDURE Init
		SELECT cData ,table2ID ;
			FROM table2 ;
			INTO ARRAY This.aRowsource
		This.Requery()
	ENDPROC
ENDDEFINE


ENTIRE THREAD

display problems w/ combo box in grid Posted by Ellen Solomon @ 12/24/2013 12:48:01 PM
RE: display problems w/ combo box in grid Posted by Cetin Basoz @ 12/24/2013 1:00:11 PM
RE: display problems w/ combo box in grid Posted by Stefan Wuebbe @ 12/24/2013 1:08:51 PM
RE: display problems w/ combo box in grid Posted by Cetin Basoz @ 12/24/2013 2:01:25 PM
RE: display problems w/ combo box in grid Posted by Stefan Wuebbe @ 12/24/2013 1:06:22 PM
RE: display problems w/ combo box in grid Posted by Ellen Solomon @ 12/25/2013 7:45:06 AM
RE: display problems w/ combo box in grid Posted by Stefan Wuebbe @ 12/25/2013 6:32:09 PM