1
동적으로 dgv를 만들고 있는데이 셀 클릭으로 이벤트를 만들어야합니다. 어떻게해야합니까? 지금 바로 cellclick 이벤트를 만들면 아무 것도 발생하지 않습니다.동적으로 생성 된 DataGridview 셀 클릭 이벤트가 작동하지 않습니다.
private void dataGridView2_CellClick(object sender, DataGridViewCellEventArgs e)
{
try
{
if (dataGridView2.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString().Contains("http:"))
{
Process.Start(dataGridView2.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString());
}
}
catch
{
}
}
그러나 아무것도 일어나고
dataGridView2 = new DataGridView();
DataGridViewColumn col1 = new DataGridViewImageColumn
{
ImageLayout = DataGridViewImageCellLayout.Stretch
};
DataGridViewColumn col2 = new DataGridViewImageColumn
{
ImageLayout = DataGridViewImageCellLayout.Stretch
};
DataGridViewColumn col3 = new DataGridViewTextBoxColumn();
DataGridViewColumn col4 = new DataGridViewLinkColumn();
DataGridViewColumn col5 = new DataGridViewTextBoxColumn();
DataGridViewColumn col6 = new DataGridViewTextBoxColumn();
DataGridViewColumn col7 = new DataGridViewTextBoxColumn();
col1.HeaderText = "TPM Image";
col1.Name = "image_tpm";
col1.Width = 60;
col2.HeaderText = "Find Image";
col2.Name = "image_thefind";
col2.Width = 60;
col3.HeaderText = "Name";
col3.Name = "name";
col3.Width = 150;
col4.HeaderText = "URL";
col4.Name = "product_url";
col4.Width = 100;
col5.HeaderText = "Price";
col5.Name = "price";
col5.Width = 70;
col6.HeaderText = "Accuracy";
col6.Name = "image_accuracy";
col6.Width = 52;
col7.HeaderText = "History";
col7.Name = "history";
col7.Width = 200;
dataGridView2.Columns.Add(col1);
dataGridView2.Columns.Add(col2);
dataGridView2.Columns.Add(col3);
dataGridView2.Columns.Add(col4);
dataGridView2.Columns.Add(col5);
dataGridView2.Columns.Add(col6);
dataGridView2.Columns.Add(col7);
dataGridView2.Location = new System.Drawing.Point(650, 20);
dataGridView2.Size = new System.Drawing.Size(702, 413);
this.Controls.Add(dataGridView2);
내 cellClickEvent :
코드 DGV 확인합니다.
수 있음'의 AutoPostBack = TRUE '도 GRIDVIEW 설정해야 하는가? – Cdeez
웹 사이트 응용 프로그램이 아니라 Windows 양식으로 작업하고 있습니다. – Paz
동적으로 dgv를 사용하지 않을 때 동일한 코드가 작동했습니다. 하지만 내 코드로 인해 동적으로 생성 된 dgv를 사용해야합니다. – Paz