How to from combobox selected index open another pdf file?

Help!

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ceTe.DynamicPDF.Printing;
using System.IO;
using System.Drawing.Printing;
using System.Diagnostics;

namespace Obrasci_PDF
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

            comboBox2.Items.Add("Bilans stanja");
            comboBox2.Items.Add("Bilans uspeha");
            comboBox2.Items.Add("Izveštaj o promenama na kapitalu");
            comboBox2.Items.Add("Izveštaj o promenama na kapitalu");
            comboBox2.Items.Add("Statistički aneks");
        }

        Process proc = new Process();

            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (comboBox2.SelectedIndex == 0)
            {
                proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                proc.StartInfo.Verb = "print";

                proc.StartInfo.FileName = @"C:\Program Files\Adobe\Acrobat 10.0\Acrobat\Acrobat.exe";
                proc.StartInfo.Arguments = @"C:\Users\RS\Desktop\PDF\Obrasci finansijskih izveštaja\Bilans stanja.pdf";
                proc.StartInfo.UseShellExecute = false;
                proc.StartInfo.CreateNoWindow = true;



                }


            }


        }
    }

// this code open first file,how to open second and other??

Edited 3 Years Ago by Dani: Formatting fixed

I would open file from double clicking on the item in comboBox, rather then with a button click (which is an additional - unnecessary task to do - if we are picky).

So to open more files, you can use Shitch statement, and specify what ever you need in each of the cases.

Example:

private void comboBox1_DoubleClick()
{    
    switch(comboBox1.SelectedItem.ToString())
    {
         proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
         proc.StartInfo.Verb = "print";
         proc.StartInfo.FileName = @"C:\Program Files\Adobe\Acrobat 10.0\Acrobat\Acrobat.exe";
         
         case "Bilans stanja":
         {
              proc.StartInfo.Arguments = @"C:\Users\RS\Desktop\PDF\Obrasci finansijskih izveštaja\Bilans stanja.pdf";       
              break;
         }
         case "Bilans uspeha":
         {
             proc.StartInfo.Arguments = @"C:\Users\RS\Desktop\PDF\Obrasci finansijskih izveštaja\Bilans uspeha.pdf";
             break;
         }
         //do the same for the rest
      
         proc.StartInfo.UseShellExecute = false;
proc.StartInfo.CreateNoWindow = true;
    }
}

Hope it helps,
bye

Edited 4 Years Ago by Mitja Bonca: n/a

This article has been dead for over six months. Start a new discussion instead.