Subject |
Re: combobox |
From |
Ken Mayer <dbase@nospam.goldenstag.net> |
Date |
Sat, 9 Mar 2024 12:54:28 -0800 |
Newsgroups |
dbase.getting-started |
Attachment(s) |
Charlie_Combobox.wfm, CharlieNames.dbf, CharlieNames.MDX |
On 3/9/2024 7:29 AM, Charlie wrote:
> Curious, I am trying to use a combobox which works great. What I am trying to do is list what is in the datasource and allow the user to select a name wkich is working fine. . My idea is that there be a way for the user to be able to add a name if it doesn't exist in the dropdown. I am not exactly sure how to handle this. Possibly I need to use a different component? I could use another entryfield that the user could type the name in if he doesn't find it but just wondering if there is a way that would be less confusing?
See attached -- table (with mdx) and form ...
Ken
--
*Ken Mayer*
Ken's dBASE Page: http://www.goldenstag.net/dbase
The dUFLP: http://www.goldenstag.net/dbase/index.htm#duflp
dBASE Books: http://www.goldenstag.net/dbase/Books/dBASEBooks.htm
dBASE Tutorial: http://www.goldenstag.net/dbase/Tutorial/00_Preface.htm
dBASE Web Tutorial: http://www.goldenstag.net/dbase/WebTutorial/00_Menu.htm
dBASE DOS to Windows Tutorial:
http://www.goldenstag.net/dbase/DtoWTutorial/00_Menu.htm
| ** END HEADER -- do not remove this line
//
// Generated on 03/09/2024
//
parameter bModal
local f
f = new Charlie_ComboboxForm()
if (bModal)
f.mdi = false // ensure not MDI
f.readModal()
else
f.open()
endif
class Charlie_ComboboxForm of FORM
with (this)
scaleFontName = "Calibri"
scaleFontSize = 12.0
height = 16.0
left = 73.5
top = 6.52
width = 40.0
text = ""
endwith
this.CHARLIENAMES1 = new QUERY(this)
with (this.CHARLIENAMES1)
left = 4.0
top = 11.0
width = 9.0
height = 1.0
sql = 'select * from "CharlieNames.dbf"'
active = true
endwith
with (this.CHARLIENAMES1.rowset)
indexName = "NAME"
endwith
this.TEXT1 = new TEXT(this)
with (this.TEXT1)
height = 1.0
left = 2.125
top = 0.88
width = 28.25
fontName = "Calibri"
fontSize = 12.0
text = "Combobox Example for Charlie"
endwith
this.TEXT2 = new TEXT(this)
with (this.TEXT2)
height = 1.0
left = 2.5
top = 3.44
width = 6.75
fontName = "Calibri"
fontSize = 12.0
text = "Name:"
endwith
this.COMBOBOX1 = new COMBOBOX(this)
with (this.COMBOBOX1)
onChange = class::COMBOBOX1_ONCHANGE
height = 1.0
left = 2.25
top = 4.68
width = 29.625
fontName = "Calibri"
fontSize = 12.0
dataSource = form.charlienames1.rowset.fields["name"]
style = 1 // DropDown
endwith
this.ENTRYFIELD1 = new ENTRYFIELD(this)
with (this.ENTRYFIELD1)
height = 1.0
left = 3.375
top = 7.16
width = 27.0
fontName = "Calibri"
fontSize = 12.0
value = "Another control to get focus"
maxLength = 28
endwith
this.rowset = this.charlienames1.rowset
function COMBOBOX1_onChange()
// fires when leaving the combobox ...
private r, f, cName, bFound
// shortcuts
r = form.rowset
f = r.fields
cName = this.value // combobox value
// navigate to first row:
r.first()
bFound = false
do while not r.endOfSet // loop to end
if cName.toUpperCase().rightTrim().leftTrim() == ;
f["Name"].value.toUpperCase().rightTrim().leftTrim()
bFound := true
exit // no need to continue looking
endif
r.next() // next row
enddo
if not bFound
if msgbox( "Do you want to add this name to the table?", ;
"Name not found!", 36 ) == 6
// add a new record:
r.beginAppend()
// add the name:
f["Name"].value := cName
// save it:
r.save()
// now re-load the datasource:
this.dataSource := this.dataSource
endif // msgbox
endif // not bFound
return
endclass
|
|