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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using dynamicCurrentControl refuses editing in grid

Status
Not open for further replies.

andre65

Programmer
Jan 19, 2003
95
NL
I have a grid with 2 columns. The second columns has next the default Textbox1 the controls txtNum and txtChar and cmbJaNee. The following setting for the grid:

table: aTable
columns: type n(2); num_value n(10); char_value c(100)

grid.recordSource = [aTable]
grd.columns(2).bound = .f.
grd.columns(2).controlSource = [(iif(aTable.type=1,alltrim(str(aTable.num_value)),iif(aTable.type=2,aTable.char_value,iif(aTable.num_value=1,'YES','NO'))))]
grd.columns(2).txtNum.controlSource = [aTable.num_value]
grd.columns(2).txtChar.controlSource = [aTable.char_value]
grd.columns(2).cmbJaNee.controlSource = [aTable.num_value]
grd.columns(2).cmbJaNee.rowSourceType = 1
grd.columns(2).cmbJaNee.rowSource = 'YES,NO'
grd.columns(2).dynamicCurrentControl = [(iif(aTable.type=1,'txtNum',iif(aTable.type=2,'txtChar','cmbYesNo')))]

Now when clicking column 2 for a numeric value, the focus goes from txtNum out of the grid to the next control. When tabbing to column 2 the focus stays on txtNum display value X. Editting is not possible.

Now when clicking column 2 for a character value, the focus stays on txtChar display empty. Editting is not possible.

Now when clicking column 2 for a Yes/No value, the combo is displayed and I can make a selection.

Now why does the cmbYesNo work, and txtNum and txtCahr does not work?
How can I make txtNum and txtChar editting?

Gr,
André
 
Because you're doing everything to column #2 and the last thing sticks. Might want to consider using:

Code:
DO CASE

  CASE aTable.type=1
    *all related code

  CASE aTable.type=2
    *all related code

ENDCASE

Brian
 
Baltman,

I have changed the following

grid.columns(2).controlSource = [thisform.m_get_value()]
grid.columns(2).dynamicCurrentControl = [thisform.m_get_control()]

method thisform.m_get_control:
do case
case aTabletype=1
lcControl = [txtNum]
case aTabletype=1
lcControl = [txtChar]
otherwise
lcControl = [cmbJaNee]
endcase
return lcControl

method thisform.m_get_value:
do case
case aTabletype=1
lcValue = alltrim(str(aTable.num_value))
case aTabletype=1
lcValue = aTable.char_value
otherwise
lcValue = iif(aTable.num_value=1,[YES],[NO])
endcase
return lcValue

Unfortunately the same result
Any other suggestion?

Gr,
André
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top