Page 1 of 1

WinForms

PostPosted: Wed Dec 03, 2008 2:28 am
by Charles
I was updating the WinForms HowTo and made some discoveries:

-- You can leave off the type of the "sender" in an event handler. This is just a normal Cobra thing for dynamically typed arguments. Since .NET sees such arguments as type System.Object there is no conflict, but the upshot is that you can immediately access the properties and methods of the sender such as .text and .tag.
class MyForm
# ...
def handleClick(sender, args as EventArgs)
MessageBox.show(this, 'You clicked [sender.text]/[sender.tag]', 'Click')

-- If you leave out "-t:winexe" on the command line, then you can see the output of print and trace statements in your program.
Code: Select all
cobra MyForm.cobra
<print output here>

If you're doing WinForms programming, update your workspace and take a look at <workspace>\HowTo\380-WinForms.cobra