Issues getting OpenFileDialog to work
Posted: Sun Jan 24, 2010 12:07 pm
When I compile and run the following code, and select the "..." button, it gives a message box (my test to confirm the event fired) but then hangs when trying to show the dialog.
Can you pass on any pointers as to what I'm doing wrong or missing? The original goal was to try and learn Cobra by implementing http://cobra-language.com/trac/cobra/wiki/PortingC ... but I didn't get far :-/
Thanks,
Sean
Can you pass on any pointers as to what I'm doing wrong or missing? The original goal was to try and learn Cobra by implementing http://cobra-language.com/trac/cobra/wiki/PortingC ... but I didn't get far :-/
Thanks,
Sean
- Code: Select all
use System.Windows.Forms from "System.Windows.Forms"
class CSharp2Cobra inherits Form
var _txtFile as TextBox
var _lblFile as Label
var _btnBrowse as Button
var _btnConvert as Button
var _panel as FlowLayoutPanel
cue init
base.init
.text = 'C# to Cobra Converter'
_panel = FlowLayoutPanel(parent=this, dock=DockStyle.Fill, flowDirection=FlowDirection.TopDown)
_lblFile = Label(parent=_panel, autoSize=true,text='File Name:')
_txtFile = TextBox(parent=_panel, width=300, text='')
_btnBrowse = Button(parent=_panel, autoSize=true, text='...', tag=1)
listen _btnBrowse.click, ref .browseFile
_btnConvert = Button(parent=_panel, autoSize=true, text='Two', tag=2)
listen _btnConvert.click, ref .handleClick
def browseFile(sender, args as EventArgs)
MessageBox.show(this, 'You clicked [sender.text]/[sender.tag]', 'Click')
dlg = OpenFileDialog()
#dlg.filter = "C# files|*.cs"
#dlg.filterIndex = 1
result = dlg.showDialog
#if dlg.showDialog == DialogResult.OK
# _txtFile.text = dlg.fileName
def handleClick(sender, args as EventArgs)
MessageBox.show(this, 'You clicked [sender.text]/[sender.tag]', 'Click')
class Program
def main is shared
Application.run(CSharp2Cobra())