Forums

WinForms

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

WinForms

Postby Charles » Wed Dec 03, 2008 2:28 am

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
Charles
 
Posts: 2515
Location: Los Angeles, CA

Return to Discussion

Who is online

Users browsing this forum: No registered users and 101 guests