Space = =CHR(168) && This is the space replacement characterThen I have the following methods defined:
Procedure KeyPress LPARAMETERS nKeyCode, nShiftAltCtrl LOCAL lcBegText, lcEndText DO CASE CASE nKeyCode = 7 && Delete key DO CASE CASE this.SelLength >= LEN(this.Tag) .AND. this.SelStart = 0 lcBegText = "" lcEndText = "" CASE this.SelLength > 0 .AND. this.SelLength < LEN(this.Tag) lcBegText = LEFT(this.Tag,this.SelStart) lcEndText = SUBSTR(this.Tag,this.SelStart+this.SelLength+1) OTHERWISE lcBegText = LEFT(this.Tag,this.SelStart) lcEndText = SUBSTR(this.Tag,this.SelStart+2) ENDCASE this.Tag = lcBegText + lcEndText CASE nKeyCode = 127 && Backspace key IF this.SelLength = 0 lcBegText = IIF(this.SelStart>1,LEFT(this.Tag,this.SelStart-1),"") lcEndText = SUBSTR(this.Tag,this.SelStart+1) ELSE lcBegText = IIF(this.SelStart>1,LEFT(this.Tag,this.SelStart),"") lcEndText = SUBSTR(this.Tag,this.SelStart+this.SelLength+1) ENDIF this.Tag = lcBegText + lcEndText CASE BETWEEN(nKeyCode,32,126) && Printable key DO CASE *-* Inserting character end of text CASE this.SelStart = LEN(this.Tag) .AND. this.SelLength = 0 lcBegText = this.Tag lcEndText = "" *-* Inserting character in mid text CASE this.SelStart < LEN(this.Tag) .AND. this.SelLength = 0 lcBegText = LEFT(this.Tag,this.SelStart) lcEndText = SUBSTR(this.Tag,this.SelStart+1) *-* Replacing character(s) CASE this.SelStart < LEN(this.Tag) .AND. this.SelLength > 0 lcBegText = LEFT(this.Tag,this.SelStart) lcEndText = SUBSTR(this.Tag,this.SelStart+this.SelLength+1) OTHERWISE WAIT WINDOW "ERROR: Unhandled Keyboard Entry" lcBegText = this.Tag lcEndText = "" ENDCASE this.Tag = lcBegText + CHR(nKeyCode) + lcEndText ENDCASE this.Tag = STRTRAN(this.Tag,CHR(32),this.Space) EndProc Procedure GotFocus this.DisplayValue = this.Tag EndProcI initialize the Tag property with the initial value for display. This way if the user had trailing spaces in the initial text, they will be preserved. The space is replaced in the Tag property with the Space property value. I have set the Space property to the value Ascii 168 which seemed to be the least offensive. I tried using 160 (which for the Arial font is blank) but the dropdown combo would still trim it from the display value.