![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
Outlook 2007, VS2008 with VSTO
I know about creating form regions, associating them with custom message classes, adding controls to them, using the FormRegionShowing event to fill the controls with data and so forth. I'm having difficulty making some fundamental connection that I'd appreciate pointers to information about. I have buttons on the ribbon that are going to take action with the information that's in the controls on the formregion. I need to get to the controls to collect the data in them and save it off (in this particular case, they're going to be sent to a database via a web service). In the button click event handler, how do I get a hold of the object handle for the form region? I thought about traversing the object hierarchy from the ActiveInspector and that does lead to the ModifiedFormPages property (holding a Pages) collection but when I check that property within the event handler I find it's got a count of 0 even though I have a postItem with a my form region showing. So I'm kind of scratching my head about how to traverse down the object hierarchy to the form region. Should I take an alternative path and call the Close method on the active inspector and hang my data collection and saving work in the FormRegionClosed event? |
Ads |
#2
|
|||
|
|||
![]()
When your init code is called to initialize the form region it probably is
passing an Outlook.FormRegion interface object. I do that in the BeforeFormRegionShow() event handler. In that handler I call to Init() and pass the FormRegion object passed to BeforeFormRegionShow() as "Region". That FormRegion object is used to hook up the Close() and Expanded() event handlers. The item showing the form region is Region.Item and the form region form is Region.Form. You can then cast the FormRegion.Form object to a Forms.UserForm object: private Forms.UserForm _form; // at class level // in init code _form = (Forms.UserForm)Region.Form; That lets you get the Controls collection of the form region, from there it's easy to read/write the values in various controls in the form region. For any controls that I might want to access later on I usually set up variables to make it easy to access the control and its value later on. So I might declare something like this for a form region date control: private Outlook.OlkDateControl _timeToStartDate; Then in my InitControls() code called from my Init() procedure I use something like this: _timeToStartDate = (Outlook.OlkDateControl)_form.Controls.Item("olkTr avelToStartDate"); Where "olkTravelToStartDate" is the name of a date control on the form region. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "Mark Lawrence" wrote in message ... Outlook 2007, VS2008 with VSTO I know about creating form regions, associating them with custom message classes, adding controls to them, using the FormRegionShowing event to fill the controls with data and so forth. I'm having difficulty making some fundamental connection that I'd appreciate pointers to information about. I have buttons on the ribbon that are going to take action with the information that's in the controls on the formregion. I need to get to the controls to collect the data in them and save it off (in this particular case, they're going to be sent to a database via a web service). In the button click event handler, how do I get a hold of the object handle for the form region? I thought about traversing the object hierarchy from the ActiveInspector and that does lead to the ModifiedFormPages property (holding a Pages) collection but when I check that property within the event handler I find it's got a count of 0 even though I have a postItem with a my form region showing. So I'm kind of scratching my head about how to traverse down the object hierarchy to the form region. Should I take an alternative path and call the Close method on the active inspector and hang my data collection and saving work in the FormRegionClosed event? |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Form Region cannot be opened | shubhangi | Add-ins for Outlook | 3 | April 18th 08 02:11 PM |
Form Region below Send Button | Vela | Add-ins for Outlook | 4 | January 25th 08 08:15 PM |
'adjoining' form region | Alan | Outlook - Using Forms | 1 | May 29th 07 05:42 PM |
Communicate with a Form Region | Vbasiccode | Outlook - Using Forms | 5 | May 9th 07 10:51 PM |
only one instance of form region is displayed | Nikolas | Outlook - Using Forms | 4 | October 6th 06 03:37 PM |