开发者

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
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜