B4J Question Filechooser how to detect Cancel click

ThRuST

Well-Known Member
Licensed User
Longtime User
Hi I wonder how to detect cancel click in filechooser? I tried this

B4X:
Dim fc As FileChooser
fc.Initialize
Dim filename As String = fc.ShowOpen(MainForm)

If fc = fx.DialogResponse.CANCEL Then
    ' code
End If

Thanks,
ThRuST
 

ThRuST

Well-Known Member
Licensed User
Longtime User
And for all the lamers out there that is new to programming here's the solution :D

B4X:
Dim fc As FileChooser
fc.Initialize
Dim filename As String = fc.ShowOpen(MainForm)

If filename = "" Then
' No file choosen

Else
' User choosed a filename

End If
 
Upvote 0

EnriqueGonzalez

Expert
Licensed User
Longtime User
That happens, its normal for us to overcomplicated ourselves,

watch out when you copy paste from the forums tags, they will mess the formatting, look at your 2nd line!
 
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
Btw how to change the default extension and path? (Please do not start a new question for this follow-up questions)
 
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
Enrriqueee, pleeaassee Amiiigo, hurryy to answerrr myy quesstion. Coding caanoottt waitt
 
Upvote 0

EnriqueGonzalez

Expert
Licensed User
Longtime User
i am sorry!!

this is how.
B4X:
    fc.Title="Select Photo"
    fc.InitialDirectory = "C:\Proyectos"
    fc.SetExtensionFilter("Image",Array As String("*.jpg","*.png","*.bmp"))
 
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
Stole this code from Fabrice La

B4X:
fc.InitialFileName = "excelfile.xls"
fc.SetExtensionFilter("Excel Files",Array As String("*.xls"))
 
Upvote 0