{"id":310,"date":"2010-07-07T14:38:57","date_gmt":"2010-07-07T14:38:57","guid":{"rendered":"https:\/\/ibex.tech\/visualcpp\/?p=310"},"modified":"2022-02-17T06:24:05","modified_gmt":"2022-02-17T06:24:05","slug":"events-for-multiple-form-objects-what-object-called-an-event","status":"publish","type":"post","link":"https:\/\/ibex.tech\/visualcpp\/forms\/events-for-multiple-form-objects-what-object-called-an-event","title":{"rendered":"Function For Multiple Form Objects &#8211; What Object Called An Event?"},"content":{"rendered":"<p>\nYou can assign the same event to multiple controls. When called the &quot;object sender&quot; portion will be a reference to whatever one of the controls was clicked.<br \/>\nThe EventArgs portion is a way to pass extra information to the event handler. Some events use a derivative of EventArgs which contain extra information.\n<\/p>\n<p>\nThe function will be defined somethng like this (like any function thats auto generated for a form object):\n<\/p>\n<pre>\r\n<code>private: System::Void MySpecialFunction_Click(System::Object^  sender, System::EventArgs^  e)<\/code><\/pre>\n<p>\nEnter the funciton name in the form objects click event property\n<\/p>\n<p>\nIn the function we can do this:-\n<\/p>\n<pre>\r\n<code>\tif (sender == btnMyButton)\t\t\/\/Was sender a specific control \/ object:<\/code><\/pre>\n<p>\nOr if we want to get at some property of the sender (for instance its state or its text field):\n<\/p>\n<pre>\r\n<code>\r\n\tToolStripMenuItem ^ClickedItem = dynamic_cast&lt;toolstripmenuitem^&gt;(sender);\r\n\tif (ClickedItem != nullptr)\r\n\t{\r\n\t\tString ^MyString = ClickedItem-&gt;Text;\r\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>You can assign the same event to multiple controls. When called the &quot;object sender&quot; portion will be a reference to whatever one of the controls was clicked. The EventArgs portion is a way to pass extra information to the event handler. Some events use a derivative of EventArgs which contain extra information. The function will [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25],"tags":[],"class_list":["post-310","post","type-post","status-publish","format-standard","hentry","category-forms"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/posts\/310","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/comments?post=310"}],"version-history":[{"count":4,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/posts\/310\/revisions"}],"predecessor-version":[{"id":1391,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/posts\/310\/revisions\/1391"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/media?parent=310"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/categories?post=310"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/tags?post=310"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}