none
Resizing an Outlook Form Region programmatically to match height of the FormRegionControl within it RRS feed

  • Question

  • Hi all

    I would like to know how to make an "adjoining" Outlook Form Region resize in height to match the height of the FormRegionControl within it.

    The FormRegionControl inside my Outlook Form Region can grow in height dynamically at runtime.  However, whenever it does grow in height, the Outlook Form Region doesn't grow to match the contents (unless I manually collapse and re-expand the Outlook Form Region).  Outlook gives the region a scrollbar instead.  Is there a way to make the Outlook Form Region automatically grow in height to accommodate the size of the control within it instead of adding a scrollbar?

    I'm using VSTO with VS2008, .NET 3.5 and Office 2007.  Any help would be appreciated.

    Many thanks
    Wayne

    Monday, June 16, 2014 2:02 PM

Answers

  • I've already tried. It doesn't seem to make any difference. My control is larger at design-time, and I reduce it's height at runtime to the appropriate size.  The problem is that Outlook seems to remember the previous region size when you choose another email, and if the region now needs to be larger than it was last time, the region doesn't grow to accommodate the larger form region control - it just adds a vertical scrollbar.  The weird thing is that if i then collapse the region and then re-expand it, the region will resize to show the entire form region control without a scrollbar.  If only there was a way to programmatically do this...

    I think I'm going to redesign my solution so that it will work with a fixed height region.  Probably easier :-)

    Thanks for your help Ken.

    Wayne.

    Wednesday, June 18, 2014 8:55 AM

All replies

  • I'm not sure if it would work if you're using the designer, but have you tried the Reflow() method of the FormRegion object? That's supposed to do what you're looking to do.

    Ken Slovak MVP - Outlook

    Monday, June 16, 2014 2:07 PM
    Moderator
  • Hi Ken

    Thanks for your response.

    I am already calling Reflow() method.

    I've tried adding a single button to my form region control with the following click event...

        Private Sub butResize_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butResize.Click
            Me.Height += 40
            Me.OutlookFormRegion.Reflow()
        End Sub

    This should increase the height of the outlook form region by 40 pixels each time I click the button.  It does, but the form region gains a scrollbar instead of actually growing in height.

    If I use "Me.Height -= 40" instead (to reduce the height by 40 each time), then it resizes fine.  It's just a problem when increasing the height beyond what is currently visible in the outlook form region panel.

    Thanks

    Wayne

    Monday, June 16, 2014 2:56 PM
  • Unfortunately that's about all there is. Does it help if the design is made at full size and then things are scaled down from there? Does Reflow() work better then?

    Ken Slovak MVP - Outlook

    Monday, June 16, 2014 5:40 PM
    Moderator
  • I've already tried. It doesn't seem to make any difference. My control is larger at design-time, and I reduce it's height at runtime to the appropriate size.  The problem is that Outlook seems to remember the previous region size when you choose another email, and if the region now needs to be larger than it was last time, the region doesn't grow to accommodate the larger form region control - it just adds a vertical scrollbar.  The weird thing is that if i then collapse the region and then re-expand it, the region will resize to show the entire form region control without a scrollbar.  If only there was a way to programmatically do this...

    I think I'm going to redesign my solution so that it will work with a fixed height region.  Probably easier :-)

    Thanks for your help Ken.

    Wayne.

    Wednesday, June 18, 2014 8:55 AM