datagrid, new form, selectrow
-
hi there. I have a problem. I want to select a row from the datagrid en put that in tekstboxes in a new form. this is what i've got so far:
public delegate void CustomRowHandler(object sender, CustomRowEventArgs e); public static event CustomRowHandler CustomRow; ---------------------------------------------------------- public void dataGrid_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) { int rowIndex = dataGrid.CurrentRowIndex; if (CustomRow != null) { CustomRow(this, new CustomRowEventArgs(barry11,dataGrid, rowIndex)); ---------------------------------------------------------------- public class CustomRowEventArgs : EventArgs { Barry1 barry11; DataGrid grid; int row; public CustomRowEventArgs(Barry1 DSet,DataGrid Grid,int Row) { barry11 = DSet; grid = Grid; row = Row; } public Barry1 DSet { get { return barry11; } } public DataGrid Grid { get { return grid; } } public int Row { get { return row; } }
---------------------------------------------------- and on my second form.. -----------------------------------------------------private void customHandler_CustomRow(object sender, WindowsApplication30.CustomRowEventArgs e) { Barry1 DSet = e.DSet; DataGrid grid = e.Grid; int row = e.Row; editLASTNAME.Text = e.DSet.Tables[0].Rows[e.Row]["Firstname"].ToString(); } InitializeComponent(); Form1.CustomRow += new WindowsApplication30.CustomRowHandler(customHandler_CustomRow); public DataForm1(Barry1 barry11, DataGrid dataGrid, int rowIndex)
so.. if i put this peace of code from the second form in to my first form.. it words... if i put this peace of code in to my first form.. public void dataGrid_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) { int rowIndex = dataGrid.CurrentRowIndex; if (CustomRow != null) { CustomRow(this, new CustomRowEventArgs(barry11,dataGrid, rowIndex)); DataForm1 frm = new DataForm1 (barry11,dataGrid, dataGrid.CurrentRowIndex); frm.Show(); he opens the second form (DataForm1). he fills the textfield that was on the first form.. but he doesn's fill the textfield on the second form... can someone please help me