i have dialogbox cancel button called follows:
dim dlgsizselection new dlgtyresizeselection(objcarwebvehicle.tyres, objcarwebvehicle) if (dlgsizselection.showdialog) = windows.forms.dialogresult.ok selectedtyre = ctype(dlgsizselection.lsttyreoptions.selecteditem, carwebvehiclecom.tyredata) dlgsizselection.close() elseif (dlgsizselection.showdialog) = windows.forms.dialogresult.cancel dlgsizselection.close() exit sub else msgbox("no tyre sizes selected.", msgboxstyle.exclamation, "tyre search") dlgsizselection.close() exit sub end if
however, when set dialogreturn property in form calling follows:
dialogresult = windows.forms.dialogresult.cancel
and press cancel button, flashes briefly dialog box reappears have pressed nothing , in order close have press second time.
what missing?
first of all: don't call close after modal dialog returns. modal dialog closes automatically.
you code problematic following reason: you're calling showdialog
more once. if code determines ok wasn't clicked, shows dialog again, waiting user click again.
if (dlgsizselection.showdialog) = windows.forms.dialogresult.ok ... elseif (dlgsizselection.showdialog) = windows.forms.dialogresult.cancel ... end if
declare local variable holds result of single call showdialog
, things work fine:
dim result windows.forms.dialogresult = dlgsizselection.showdialog if (result = windows.forms.dialogresult.ok) .... elseif (result = windows.format.dialogresult.cancel) .... else .... end if
don't call close
, no need exit sub
.
Comments
Post a Comment