I have a DataGridView as seen in the picture and a OpenFileDialog has to open when I click on "Browse from file". I believe there is no way to become possible if i write my code under the button_Click methods but i dont know under which method to write my code. Please help.
As far as now I have made this: (hope it helps)
string[] col2 = new string[dataGridView1.Rows.Count];
for (int i = 0; i < dataGridView1.Rows.Count; i++)
if (col2[i] == "Browse From File...")
{
DialogResult result2 = openFileDialog2.ShowDial开发者_运维知识库og();
if (result2 == DialogResult.OK)
{
filename = openFileDialog1.FileName;
}
}
Place your code in the DataGridView.CellValueChanged
event. Use the SelectedCells
property to find the current cell, then check if its value is "Browse From File...". If so, fire off the OpenFileDialog.ShowDialog()
call.
See this documentation for CellValueChanged: http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.cellvaluechanged.aspx
精彩评论