I have an application that I want to display multiple PDF documents. If I define the control at design time I can load a document and display it, but when I dynamically create the control during run time I cannot get it to display. The document is being displayed in a tab.
Here is my code...
AxAcroPDF newPDF = new AxAcroPDF();
newPDF.CreateControl();
newPDF.Width = selectedTab.Width;
newPDF.Height = selectedTab.Height;
newPDF.LoadFile(filePath);
selectedTab.Controls.Add(newPDF);
newPDF.Show();
newPDF.Visible = true;
How do I get the PDF to display?
This is what worked for me...
AxAcroPDF newPDF = new AxAcroPDF();
selectedTab.Controls.Add(newPDF);
newPDF.CreateControl();
newPDF.Width = selectedTab.Width;
newPDF.Height = selectedTab.Height;
newPDF.LoadFile(filePath);
newPDF.Show();
For some reason it doesn't like the PDF control being added to the tab after the CreateControl() method is executed.
Don't use Width
and Height
but ActualWidth
and ActualHeight
from the SelectedTab. Under certain circumstances the non actuals may report zero sizes.
Otherwise hard code height and width to see if that provides an insight as to whether it is showing up, but hidden.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With