Click here to Skip to main content
15,918,596 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hi All,

I need to fit WindowsFormsHost to container when form size change. I have try
with using below code. But It will not work.
C#
<Border Grid.Row="4" Grid.ColumnSpan="1" Style="{StaticResource bStyle}">
         <WindowsFormsHost HorizontalAlignment="Stretch" 
         Name="FrmHostEmpAtt" VerticalAlignment="Stretch" Grid.ColumnSpan="1" 
                                  Focusable="False" IsManipulationEnabled="False"        Padding="2"
                                  ClipToBounds="True">
                    <rv:ReportViewer x:Name="RptEmpAttViwer"/>
                </WindowsFormsHost>
</Border>


Plese help me
Thanks,
Chamara
Posted

1 solution

Hi,

Rather than using Border, you should place the WindowsFormHost in the Grid Control which will automatically resize with the window. Also if you are placing the Control in a row then try to keep the Height of that RowDefinition to "*"

For example in your code its Row no 4.
C#
<grid grid.row="4" grid.columnspan="1" style="{StaticResource bStyle}">
     <windowsformshost horizontalalignment="Stretch" name="FrmHostEmpAtt" verticalalignment="Stretch" grid.columnspan="1" focusable="False" ismanipulationenabled="False" padding="2" cliptobounds="True">
                    <rv:reportviewer x:name="RptEmpAttViwer" xmlns:x="#unknown" xmlns:rv="#unknown" />
     </windowsformshost>
</grid>


Regards,
Darshan.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900