Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

combox in grid won't display content after lostfocus

Status
Not open for further replies.

koklimabc

Programmer
Jun 17, 2013
49
MY
Dear all,

I've one question need to seek for help and I've attached picture to make to clear to understand.I'm using grid's style as '0' to allows for typed in data and insert methods by append items into combox list without assign cursor/alias into grid column's rowsource.

My problem is here where I type any item which is not contained in combox list and it would append in combobox and make a selection index in automatically. It suppose display its content after lostfocus when i switched focus to next column by pressing "Enter" button but it won't. FYI, i m using VFP 6.0 and I've done with troubleshooting by assign "boundto" to my grid's class as I take it from " but it is same.

Coding in Myform keypress's Event
do case
case nKeyCode = 13 => Respond for "Enter" Button

if _screen.activeform.activecontrol.name = "grid_list"
Nodefault
curcontrol = this.grid_list
curcolumn = curcontrol.activecolumn

do case
case curcolumn = 9 => Column 'UOM' where it is

local vl_ret1stcur
vl_ret1stcur = .f.

selindex = 1
for count_ = 1 to this.grid_list.columns(9).com_uom.listcount - 1

if alltrim(this.grid_list.columns(9).com_uom.list(count_)) == ;
alltrim(this.grid_list.columns(9).com_uom.displayvalue)

vl_ret1stcur = .t.
selindex = count_
endif

next

if vl_ret1stcur = .f. => Responsible add into list if not item found on combox list
this.grid_list.columns(9).com_uom.addlistitem( ;
alltrim(this.grid_list.columns(9).com_uom.displayvalue), ;
this.grid_list.columns(9).com_uom.newitemid + 1)

lstitemid = this.grid_list.columns(9).com_uom.listcount=> Pick the selection index
else
lstitemid = selindex
endif

this.grid_list.columns(9).com_uom.displayvalue = ;
this.grid_list.columns(9).com_uom.list(lstitemid)


curcontrol.columns(16).com_gl.setfocus()
curcontrol.columns(10).setfocus() => setfocus on next column
curcontrol.columns(10).text1.selstart = 0
return
endcase

Coding in my grid's class
Define class com_bund as combobox
style = 0
boundto = .t. => This things won't worked for me.

procedure click

this.parent.parent.columns(16).com_gl.setfocus()
this.parent.parent.columns(10).setfocus()
this.parent.parent.columns(10).text1.selstart = 0

endpro

procedure init => Using insert methods without assign rowsource here

this.clear()

this.addlistitem(SPACE(7),this.newitemid + 1)

sele uom_
go top
do while !EOF()
this.addlistitem(alltrim(uom),this.newitemid+1)
skip
enddo

this.refresh()

endpro

enddefine

Appreciate thanks to any helps.
 
Sparse conrtrols the visibility of controls.

You have problems with comboboxes in grids, therefore I only use them in the active row and when off the row display the choice in a separate text column of the cursor just added for the grid. I switch that in BeforeRowColChange and AfterRowColChange events.

Bye, Olaf.
 
Dear olaf,

sorry about my missed provided code, here it is where I've put it under grid_list.init()

with this
.addobject("column9","column")
.columns(9).bound = .t.
.columns(9).visible = .t.
.columns(9).width = 75
.columns(9).header1.alignment = 2
.columns(9).header1.caption = "UOM"
.columns(9).removeobject("text1")
.columns(9).addobject("com_uom","com_bund")
.columns(9).currentcontrol = "com_uom"
.columns(9).com_uom.visible = .t.
.columns(9).com_uom.readonly = .f.
.columns(9).sparse = .f.
endwith
 
You have problems with comboboxes in grids despite how you set sparse. I forgot to mention that. My solution is to use them Sparse = .T. only and display their displayvalue in a separate field while the record is not active in it's normal text1 box.

You can't solve this by simply setting column.sparse = .F.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top