private void colourSettingsButton_Click(object sender, EventArgs e) { ColourSettings colourSettings; string filePath; DataGridViewSelectedRowCollection selectedRows = fileBatchDataGridView.SelectedRows; // bug out if there aren't any rows selected if (selectedRows.Count == 0) { MessageBox.Show( "To prevew colour settings, you must first select an image to preview from the list below", "No Image Selected", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } filePath = fileBatchDataGridView.SelectedRows[0].Cells["RealFileColumn"].Value.ToString(); try { colourSettings = new ColourSettings(filePath); colourSettings.CompressionSettings = compressionSettings.Indexed; colourSettings.ShowDialog(); } catch (Exception) { MessageBox.Show( "The selected image could not be loaded.", "Invalid Image", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (colourSettings.DialogResult == DialogResult.OK) { compressionSettings.Indexed = colourSettings.CompressionSettings; } }