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??
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
Thanks!
You are welcome.
So, have you managed to make your code working?
Yes working perfect :)
Then you can mark this thread as being answered.
thx
bye, bye
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.