Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Combo with BoundTo = .T. in Grid
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Titre:
Combo with BoundTo = .T. in Grid
Divers
Thread ID:
00150601
Message ID:
00150601
Vues:
71
Hi All,

(Using VFP5a and VFP6 on Win95, and Win95 OSR2)

I just blew a weekend fighting a ComboBox with BoundTo = .T. in a Grid! Hopefully someone can see my error (Besides allowing editing in a Grid<s>) I did find a thread from July discussing this, but I didn't find a resolution.

Anyway...
When the Combo is bound to an Integer (or Numeric with 0 decimals), the DisplayValue is blank whenever the Combo has focus. Also, the Dropdown list starts at the top no matter what the Value is. When you leave the Column with the Combo, the DisplayValue shows again. If you do make a change, the buffer is updated properly.

I also discovered if you bind a Numeric with 2 decimals and use Style = 0 (DropDownCombo), the DisplayValue has a decimal point overlaying the text. Wierd!

What I finally discovered is this: even though the Combo is bound to an Integer, the Value has 2 decimals. I tried set decimal to 0 with the same result.
When the combo is not in a grid, this doesn't seem to matter.

I have attached a program that creates 2 free tables and runs a form with a grid bound to an Integer, Numeric 0 dec, Numeric 2 Dec - List, Numeric 2 Dec - Combo.
Below the grid I have the same combos. The read-only textboxes on the bottom show the Value of the grid Combos.

I just converted all my Primay Keys to Integer as per the FPA articles and now I find this "feature" in the ComboBox.
Any Ideas would be appreciated. At the moment it looks like I can't use the ComboBox in a grid for lookups.

TIA,
Bill

** BoundTo.Prg
** Create Lookup table - RowSource of Combo
CREATE TABLE T_LookUp (L_Descr c(10), L_Int i, L_Num0 n(6,0), L_Num2 n(8,2))
** These Indicies did't affect the test. I tested with and without.
index on deleted() tag deletes
index on L_Int tag L_Int
index on L_Num0 tag L_Num0
index on L_Num2 tag L_Num2

** Populate Lookup Table
INSERT INTO T_LookUp VALUES("ONE", 1, 1, 1)
INSERT INTO T_LookUp VALUES("TWO", 2, 2, 2)
INSERT INTO T_LookUp VALUES("THREE", 3, 3, 3)
INSERT INTO T_LookUp VALUES("FOUR", 4, 4, 4)
INSERT INTO T_LookUp VALUES("FIVE", 5, 5, 5)

** Create Data table - RecordSource of Grid and ControlSource of Combos out of grid
CREATE TABLE T_Data (D_Int i, D_Num0 n(6,0), D_Num2 n(8,2))
** These Indicies did't affect the test. I tested with and without.
index on deleted() tag deletes
index on D_Int tag D_Int
index on D_Num0 tag D_Num0
index on D_Num2 tag D_Num2

INSERT INTO T_Data VALUES(0, 0, 0)

PUBLIC oform1

oform1=NEWOBJECT("form1")
with oform1
with .grid1
with .grcint
.header1.Caption = "Integer"
.RemoveObject("Text1")
.AddObject("Combo1", "combobox")
with .combo1
.BoundColumn = 2
.BoundTo = .T.
.RowSource = "t_lookup.l_descr,l_int"
.RowSourceType = 6
.Style = 2
.Visible = .T.
endwith
endwith

with .grcnum0
.header1.Caption = "Numeric 0 Dec"
.RemoveObject("Text1")
.AddObject("Combo1", "combobox")
with .combo1
.BoundColumn = 2
.BoundTo = .T.
.RowSource = "t_lookup.l_descr,l_num0"
.RowSourceType = 6
.Style = 2
.Visible = .T.
endwith
endwith

with .grcnum2list
.header1.Caption = "Numeric 2 Dec - List"
.RemoveObject("Text1")
.AddObject("Combo1", "combobox")
with .combo1
.BoundColumn = 2
.BoundTo = .T.
.RowSource = "t_lookup.l_descr,l_num2"
.RowSourceType = 6
.Style = 2
.Visible = .T.
endwith
endwith

with .grcnum2combo
.header1.Caption = "Numeric 2 Dec - Combo"
.RemoveObject("Text1")
.AddObject("Combo1", "combobox")
with .combo1
.BoundColumn = 2
.BoundTo = .T.
.RowSource = "t_lookup.l_descr,l_num2"
.RowSourceType = 6
.Style = 0
.Visible = .T.
endwith
endwith
endwith
.txtInt.ControlSource = "ThisForm.Grid1.grcInt.Combo1.Value"
.txtNum0.ControlSource = "ThisForm.Grid1.grcNum0.Combo1.Value"
.txtNum2List.ControlSource = "ThisForm.Grid1.grcNum2List.Combo1.Value"
.txtNum2Combo.ControlSource = "ThisForm.Grid1.grcNum2Combo.Combo1.Value"
endwith

oform1.Show
RETURN


**************************************************
*-- ParentClass: form
*-- BaseClass: form
*
DEFINE CLASS form1 AS form

Top = 0
Left = 0
Height = 200
Width = 550
DoCreate = .T.
Caption = "BoundTo Test"
Name = "Form1"

ADD OBJECT grid1 AS grid WITH ;
ColumnCount = 4, ;
Height = 90, ;
Left = 20, ;
Panel = 1, ;
RecordSource = "t_data", ;
RecordSourceType = 1, ;
RowHeight = 28, ;
Top = 20, ;
Width = 488, ;
Name = "Grid1", ;
Column1.ControlSource = "t_data.d_int", ;
Column1.Width = 95, ;
Column1.Sparse = .F., ;
Column1.Name = "grcInt", ;
Column2.ColumnOrder = 2, ;
Column2.ControlSource = "t_data.d_num0", ;
Column2.Width = 95, ;
Column2.Sparse = .F., ;
Column2.Name = "grcNum0", ;
Column3.ColumnOrder = 3, ;
Column3.ControlSource = "t_data.d_num2", ;
Column3.Width = 120, ;
Column3.Sparse = .F., ;
Column3.Name = "grcNum2List", ;
Column4.ControlSource = "t_data.d_num2", ;
Column4.Width = 140, ;
Column4.Sparse = .F., ;
Column4.Name = "grcNum2Combo"

ADD OBJECT combo1 AS combobox WITH ;
BoundColumn = 2, ;
RowSourceType = 6, ;
RowSource = "t_lookup.l_descr,l_int", ;
ControlSource = "t_data.d_int", ;
Height = 24, ;
Left = 38, ;
Style = 2, ;
Top = 120, ;
Width = 96, ;
BoundTo = .T., ;
Name = "cboInt"

ADD OBJECT combo2 AS combobox WITH ;
BoundColumn = 2, ;
RowSourceType = 6, ;
RowSource = "t_lookup.l_descr,l_num0", ;
ControlSource = "t_data.d_num0", ;
Height = 24, ;
Left = 135, ;
Style = 2, ;
Top = 120, ;
Width = 96, ;
BoundTo = .T., ;
Name = "cboNum0"

ADD OBJECT combo3 AS combobox WITH ;
BoundColumn = 2, ;
RowSourceType = 6, ;
RowSource = "t_lookup.l_descr,l_num2", ;
ControlSource = "t_data.d_num2", ;
Height = 24, ;
Left = 232, ;
Style = 2, ;
Top = 120, ;
Width = 121, ;
BoundTo = .T., ;
Name = "cboNum2List"

ADD OBJECT combo4 AS combobox WITH ;
BoundColumn = 2, ;
RowSourceType = 6, ;
RowSource = "t_lookup.l_descr,l_num2", ;
ControlSource = "t_data.d_num2", ;
Height = 24, ;
Left = 354, ;
Style = 0, ;
Top = 120, ;
Width = 141, ;
BoundTo = .T., ;
Name = "cboNum2Combo"

ADD OBJECT TextBox1 AS textbox WITH ;
Height = 24, ;
Left = 38, ;
Top = 145, ;
Width = 96, ;
ReadOnly = .T., ;
Name = "txtInt"

ADD OBJECT TextBox2 AS textbox WITH ;
Height = 24, ;
Left = 135, ;
Top = 145, ;
Width = 96, ;
ReadOnly = .T., ;
Name = "txtNum0"

ADD OBJECT TextBox3 AS textbox WITH ;
Height = 24, ;
Left = 232, ;
Top = 145, ;
Width = 121, ;
ReadOnly = .T., ;
Name = "txtNum2List"

ADD OBJECT TextBox4 AS textbox WITH ;
Height = 24, ;
Left = 354, ;
Top = 145, ;
Width = 141, ;
ReadOnly = .T., ;
Name = "txtNum2Combo"

PROCEDURE grid1.AfterRowColChange
LPARAMETERS nColIndex
ThisForm.Refresh()
ENDPROC

PROCEDURE cboInt.LostFocus()
ThisForm.Refresh()
ENDPROC

PROCEDURE cboNum0.LostFocus()
ThisForm.Refresh()
ENDPROC

PROCEDURE cboNum2List.LostFocus()
ThisForm.Refresh()
ENDPROC

PROCEDURE cboNum2Combo.LostFocus()
ThisForm.Refresh()
ENDPROC

ENDDEFINE
**************************************************
Bill Armbrecht
VFP MCP
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform