3
Answers

How to open pdf file from my windows form?

Ask a question
Nel

Nel

12y
1.6k
1
Hello,

I want to open a pdf file when clicking the button.

I have this code so far, using the FileOpenDialogBox:

private void button1_Click(object sender, EventArgs e)
        {
           
            openFD.InitialDirectory = "C:";
            openFD.Title = "Open dogov";
            openFD.FileName = "";
           
            openFD.Filter = "PDF Files(*.pdf)|*.pdf";

            openFD.ShowDialog();
            Chosen_file = openFD.FileName;
          
            openFD.FilterIndex=1;
            openFD.FileName=Chosen_file;
            try
            {
                if (openFD.ShowDialog() == DialogResult.OK)
                {
                    textBox15.Text = this.openFD.FileName;
                 
                }
            }
           
            finally
            {
               
            }
          

        }

and I fill the textbox with the file path.
Now I would like to open the pdf file when clicking on the textbox which contains the path, but I don't know how.

Can anybody help me please?
I would appreciate any help a lot.

Answers (3)