{"id":896,"date":"2013-01-20T15:11:47","date_gmt":"2013-01-20T13:11:47","guid":{"rendered":"http:\/\/www.samlogic.net\/blog\/?p=896"},"modified":"2019-07-07T22:32:04","modified_gmt":"2019-07-07T22:32:04","slug":"how-to-add-an-activex-component-to-a-visual-basic-2010-project","status":"publish","type":"post","link":"https:\/\/www.samlogic.net\/blog\/2013\/01\/how-to-add-an-activex-component-to-a-visual-basic-2010-project\/","title":{"rendered":"How to add an ActiveX component to a Visual Basic 2010 project"},"content":{"rendered":"<p>The components in our toolboxes, for example <a href=\"https:\/\/www.samlogic.net\/components-calendar\/calendar.htm\">SamLogic Calendar Components<\/a> and <a href=\"https:\/\/www.samlogic.net\/components\/components.htm\">SamLogic Internet Components<\/a>, are based on the ActiveX technology. That\u2019s a component technology that was introduced already in 1996 by Microsoft, but it is still supported by many tools, including the latest versions of Microsoft Visual Studio and Microsoft Office.<\/p>\n<p><img decoding=\"async\" class=\"alignright\" src=\"https:\/\/www.samlogic.net\/blog\/images\/product-components-calendar\/scc-calendar-jan-2013.gif\" alt=\"1 month calendar\" border=\"0\">In this blog post we will show how to add an ActiveX component (control) to a <strong>Visual Basic 2010<\/strong> project by using <strong>Microsoft Visual Studio 2010<\/strong>. We will add our one month calendar component from the <strong>SamLogic Calendar Components<\/strong> tool box to the Visual Basic project.<\/p>\n<p>If you want to use the calendar component in your own project you must install SamLogic Calendar Components first. But you can also consider this tip as a general step-by-step tip that shows how to insert an ActiveX component into a VB 2010 project. The steps are the same also if you add another ActiveX component to your project.<\/p>\n<p><strong>How to add an ActiveX component to a Visual Basic 2010 project<\/strong><\/p>\n<p>1. Start Visual Studio 2010 and open a Visual Basic 2010 project, or create a new project. The project type must be <strong>Windows Form Application<\/strong>.<\/p>\n<p>2. Right-click over the <strong>Toolbox<\/strong> window.<\/p>\n<p>3. Select the <strong>Choose items<\/strong> menu item in the local menu that is shown.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.samlogic.net\/blog\/images\/product-components-calendar\/menu-toolbox-choose-items.gif\" alt=\"Menu\" border=\"0\"><\/p>\n<p>4. The <strong>Choose Toolbox Items<\/strong> dialog box is now shown. In this dialog box, open the <strong>COM Components<\/strong> tab.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.samlogic.net\/blog\/images\/product-components-calendar\/dlgbox-choose-toolbox-items.gif\" alt=\"The 'Choose Toolbox Items' dialog box\" border=\"0\"><\/p>\n<p>5. If you have installed SamLogic Calendar Components and want to use the 1 month calendar, select <strong>SamLogic SLXCal Control<\/strong> in the list (in the <strong>COM Components<\/strong> tab). Otherwise, select the ActiveX component that you want to use.<\/p>\n<p>6. Click <strong>OK<\/strong> to close the dialog box.<\/p>\n<p>7. The selected component should be visible in the <strong>Toolbox<\/strong> window; probably in the bottom of the window.<\/p>\n<p>8. Now drag and drop the component on the Windows form, in the position that you want to have the component.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.samlogic.net\/blog\/images\/product-components-calendar\/vs-editor-with-1-month-calendar.gif\" alt=\"The one month calendar component placed on a Windows form\" border=\"0\"><\/p>\n<p>That\u2019s all steps that we need. We have now included an ActiveX component into a Visual Basic 2010 project and put it on a form! You can use the ActiveX component in a similar way as a visual .NET component \/ .NET class.<\/p>\n<p><strong>The calendar component\u2019s event handlers<\/strong><br \/>\nIf you double-click on the calendar component in the form, the <strong>DateChanged<\/strong> event handler is created in the source code (as seen in the picture below):<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.samlogic.net\/blog\/images\/product-components-calendar\/vs-editor-code-window-w624.jpg\" alt=\"The DateChanged event\" border=\"0\"><\/p>\n<p>The <strong>DateChanged<\/strong> event occurs when a user changes month in the calendar (for example by clicking on the right arrow). From the event handler dropdown list in Visual Studio&#8217;s source code editor you can choose another event handler for the calendar, for example the <strong>DateSelected<\/strong> event handler. The <strong>DateSelected<\/strong> event occurs when a user selects a date in the calendar by clicking on a date (day number) with the mouse button. There is also a <strong>DateDeselected<\/strong> event handler that is fired when somebody unselects a date (removes a selection) in the calendar, for example by clicking with the right mouse button.<\/p>\n<p><strong>More information about the one month calendar component<\/strong><br \/>\nMore detailed information about the one month calendar component in SamLogic Calendar Components, including a complete list of all properties, events and methods in the component, is available on this web page:<\/p>\n<p><strong><span style=\"color: #ff0000;\">&gt;<\/span><\/strong> <a href=\"https:\/\/www.samlogic.net\/components-calendar\/slcalendx.htm\">One-Month Calendar Component (ActiveX)<\/a><\/p>\n<p><strong>In the next blog post<\/strong><br \/>\nIn the <a href=\"https:\/\/www.samlogic.net\/blog\/2013\/01\/how-to-add-an-activex-component-to-an-excel-2010-sheet\/\">next blog post<\/a> we will show how to insert an ActiveX component in an Excel sheet. We will use the same calendar component as above in the example, but the tip can also be used for other ActiveX components.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The components in our toolboxes, for example SamLogic Calendar Components and SamLogic Internet Components, are based on the ActiveX technology. That\u2019s a component technology that was introduced already in 1996 by Microsoft, but it is still supported by many tools, including the latest versions of Microsoft Visual Studio and Microsoft Office. In this blog post &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.samlogic.net\/blog\/2013\/01\/how-to-add-an-activex-component-to-a-visual-basic-2010-project\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to add an ActiveX component to a Visual Basic 2010 project&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[15],"tags":[],"_links":{"self":[{"href":"https:\/\/www.samlogic.net\/blog\/wp-json\/wp\/v2\/posts\/896"}],"collection":[{"href":"https:\/\/www.samlogic.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.samlogic.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.samlogic.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.samlogic.net\/blog\/wp-json\/wp\/v2\/comments?post=896"}],"version-history":[{"count":1,"href":"https:\/\/www.samlogic.net\/blog\/wp-json\/wp\/v2\/posts\/896\/revisions"}],"predecessor-version":[{"id":6171,"href":"https:\/\/www.samlogic.net\/blog\/wp-json\/wp\/v2\/posts\/896\/revisions\/6171"}],"wp:attachment":[{"href":"https:\/\/www.samlogic.net\/blog\/wp-json\/wp\/v2\/media?parent=896"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.samlogic.net\/blog\/wp-json\/wp\/v2\/categories?post=896"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.samlogic.net\/blog\/wp-json\/wp\/v2\/tags?post=896"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}