Click here to Skip to main content
15,908,444 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all

i have grid like
XML
<Grid x:Name="grid1"  Visibility="Visible" Margin="14.717,241,0,99.685" HorizontalAlignment="Left" Width="401.283">
                       <Label Margin="90,27,197,0" Name="label12" FontSize="12" Height="26" VerticalAlignment="Top" FontWeight="Bold"></Label>
                       <Label Margin="197,27,88,0" Name="label13" FontSize="12" Height="25" VerticalAlignment="Top" FontWeight="Bold">DATE:</Label>
                       <Label HorizontalAlignment="Left" Margin="11,46.685,0,0" Name="label15" Width="80" FontSize="12" FontWeight="Bold" Height="29.315" VerticalAlignment="Top">VEHICLE No:</Label>
                       <Label Margin="11,0,0,20" Name="label16" FontSize="12" FontWeight="Bold" Height="27" VerticalAlignment="Bottom" HorizontalAlignment="Left" Width="124.545">PRICE         :</Label>
                       <Label Margin="11,0,0,37" Name="label17" FontSize="12" FontWeight="Bold" HorizontalAlignment="Left" Width="124.545" Height="30.315" VerticalAlignment="Bottom">TOTAL TIME:</Label>
                       <Label Margin="197,48,76,0" Name="label18" FontSize="12" FontWeight="Bold" Height="29.315" VerticalAlignment="Top">ARRIVAL TIME:</Label>
                       <Label Margin="90,49,197,0" Name="label21" FontSize="12" FontWeight="Bold" Height="29.315" VerticalAlignment="Top"></Label>
                       <Label Margin="197,66,76,87.315" Name="label23" FontSize="12" FontWeight="Bold">DEPARTURE TIME</Label>
                       <Label HorizontalAlignment="Left" Margin="11,24.685,0,0" Name="label11" Width="80" FontSize="12" Height="25" VerticalAlignment="Top" FontWeight="Bold">Token No    :</Label>
                       <Label FontSize="12" Height="25" HorizontalAlignment="Right" Margin="0,28,-40.76,0" Name="label28" VerticalAlignment="Top" Width="124" FontWeight="Bold"></Label>
                       <Label FontSize="12" HorizontalAlignment="Right" Margin="0,48,-9.828,0" Name="label29" Width="93.068" FontWeight="Bold" Height="28" VerticalAlignment="Top"></Label>
                       <Label FontSize="12" HorizontalAlignment="Right" Margin="0,66,-40.76,90" Name="label30" Width="124" FontWeight="Bold"></Label>
                       <Label FontSize="12" Margin="109,0,165,37" Name="label31" FontWeight="Bold" Height="30.315" VerticalAlignment="Bottom"></Label>
                       <Label FontSize="12" Margin="109,0,167,20" Name="label14" FontWeight="Bold" Height="27" VerticalAlignment="Bottom"></Label>
               </Grid>


When I clicking button
am getting printo out but it is printing whole window
except grid all remaining part left white space
i need to print only particular content in grid
i have write code like
C#
PrintDialog dialog = new PrintDialog();
          //dialog.PrintableAreaHeight=pag
          if (dialog.ShowDialog() == true)
          { dialog.PrintVisual(grid1, "My Canvas"); }


here i need to get print on only grid content not all the window
please can any one please help me.
Posted

1 solution

Printing a Control in WPF using C#


Shows how you can print a particular control, or the whole form.
 
Share this answer
 
Comments
tulasiram3975 3-Aug-11 10:17am    
i have seen this page when i print particular grid it will gives me the out put as grid content + Remaining window white space i need to print only grid content

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