Cześć,
Mój problem polega na tym, że wywala mi błąd przy kliknięciu w puste pole listBoxa, gdy jest juz coś zaznaczone to jest ok. ale jak nie ma nic zaznaczonego i klikam w puste pole to błąd.
Z listBoxa wysyłane są do PDF reader'a
System.NullReferenceException: „Odwołanie do obiektu nie zostało ustawione na wystąpienie obiektu.”
private void KPW_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
try
{
listBox1.Sorted = true;
string[] filePaths = Directory.GetFiles(@"\\srvcim-006\Dokumentacja produkcyjna\" + Folderkoncowy.Text + @"\KPW\", "*.pdf");
foreach (string filePath in filePaths)
{
listBox1.Items.Add(filePath);
}
}
catch (DirectoryNotFoundException)
{
string error = string.Format("Brak KPW");
MessageBox.Show(error, "Błąd", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void Rysunek_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
try
{
listBox1.Sorted = true;
string[] filePaths = Directory.GetFiles(@"\\srvcim-006\Dokumentacja produkcyjna\" + Folderkoncowy.Text + @"\Rysunek\", "*.pdf");
foreach (string filePath in filePaths)
{
listBox1.Items.Add(filePath);
}
}
catch (DirectoryNotFoundException)
{
// Let the user know that the directory did not exist.
string error = string.Format("Brak rysunku");
MessageBox.Show(error, "Błąd", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void Instrukcje_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
try
{
listBox1.Sorted = true;
string[] filePaths = Directory.GetFiles(@"\\srvcim-006\Dokumentacja produkcyjna\" + Folderkoncowy.Text + @"\Instrukcje\", "*.pdf");
foreach (string filePath in filePaths)
{
listBox1.Items.Add(filePath);
}
}
catch (DirectoryNotFoundException)
{
string error = string.Format("Brak Instrukcji");
MessageBox.Show(error, "Błąd", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
axAcroPDF1.LoadFile(listBox1.SelectedItem.ToString());
}

