What's the correct way to define a control e.g. chkTest below, in order to refer to it later e.g. .chkTest.checked - do I define it as a class variable as below, or is there a better way?
- Code: Select all
use System.Windows.Forms
class MyForm inherits Form
var chkTest as CheckBox
cue init
base.init
.text = 'Simple sample'
.width=180
.height=70
pnl = FlowLayoutPanel(parent=this, dock=DockStyle.Fill, flowDirection=FlowDirection.LeftToRight, autoSize=true)
.chkTest = CheckBox(parent = pnl, autoSize=true, text='check me')
btnTest = Button(autoSize=true, text='test')
pnl.controls.add(btnTest)
listen btnTest.click, ref .handleTestClick
def handleTestClick(sender, args as EventArgs)
MessageBox.show(this, 'Checkbox is checked: [.chkTest.checked]', 'Check the Checkbox')
class Program
def main has STAThread
Application.run(MyForm())