How can I Add rows from dataGridView to another one in c#?
I have two forms f1, f2 , F1 has textbox and datagridview f2 has also textbox 开发者_开发知识库 and datagridview
f2 is called when text changes in f1 textbox the user can use f2 textbox to filter the datagridView data after that clicks on the row
how can I do when the user clicks on the f2 datagridview row it is added to f1 dataGridView ?
You could make your own event in f2 and let f1 subscribe to it. Example:
public delegate void RowClickedHandler(DataRow dataRow);
public event RowClickedHandler RowClicked;
Just subscribe on a event that gets triggerd when a row is clicked in f2 and do this:
if(RowClicked != null)
RowClicked(dataRow); //dataRow is the row that has been clicked
UPDATE
Example on subscribing:
F2 f2 = new F2();
f2.RowClicked += new RowClickedHandler(f2_RowClicked);
private void f2_RowClicked(DataRow dataRow)
{
//Add row here
}
精彩评论