03-05-2009, 06:58 AM | #1 (permalink) |
Insane
Location: Kansas City, MO
|
Need help - How to make event handler
Hello TFP, I'm am looking for some help. The company I work for, among other things, sells some identification software. In the software you can tie card desigs to a database for printing id's. Between these two layers you build a production front end for manipulating data.
We have ordered the SDK for this software. In the software you can add an event button to the production form. You can't make the button have any function without the SDK. I am an amateur programmer mostly familiar with php so I picked c# rather than the alternative .net to write the event handler in. So I have a c compiler ready and the ability to read the code proceduraly, but I don't understand the functions it is calling or how to sort out what they are doing. I've read through the documentation, but I am left feeling like there must be some simple bridge between what I know and how this event handler business works. How do I go about learning to program an event handler/see the bigger picture? I need to see the flow. Button is pushed - ??? - action happens. I can send the SDK documentation to anybody willing to help. I'd love some advice, if even just a better place to pose the question, but I'm always confident there is a TFP'er out there that knows.
__________________
-Blind faith runs into things!- |
03-05-2009, 02:55 PM | #2 (permalink) |
Insane
Location: at home
|
C and C# are VERY diffrent things.
Following assumes C# and windows enviroment. The IDE usually generates code behind the scene for the event handling. Here is what Visual Studio generates for a button on a windows form this.button1 = new System.Windows.Forms.Button(); this.button1.Click += new System.EventHandler(this.Click); Vola!, now the procedure Click in button1 will be fired when the button is clicked. Hope this is of some help Yours Zweiblumen
__________________
Sodomy non sapiens. : I'm buggered if I know |
03-08-2009, 04:28 PM | #3 (permalink) |
Psycho
Location: Sweden - Land of the sodomite damned
|
Here is a very simple example:
Code:
using System; using System.Windows.Forms; using System.Drawing; public class MyEventHandler : Form { public MyEventHandler() { // Just setup a very very simple UI Size = new Size(200, 200); // Size of window // Create new button with the created window as parent Button myButton = new Button(); myButton.Parent = this; myButton.Text = "Click me"; // When button is clicked, run OnButtonClick myButton.Click += new EventHandler(OnButtonClick); } // Display message box when button has been clicked public void OnButtonClick(object sender, EventArgs e) { MessageBox.Show("You clicked me"); } public static void Main() { Application.Run(new MyEventHandler()); } }
__________________
If atheism is a religion, then not collecting stamps is a hobby. |
Tags |
event, handler, make |
|
|