private void btnSave_Click(object sender, EventArgs e) { IssuesCD.IssuesRow issuesRow = (IssuesCD.IssuesRow)_oneIssueDataTable.Rows[0]; if (issuesRow.IsValidRow()) { object[] keys = new object[] { _oneIssueDataTable.Rows[0]["TaskId"].ToString() }; DataTable gridDataSource = Grid.BindingSource.DataSource as DataTable; if (gridDataSource != null) { DataRow gridRow = gridDataSource.Rows.Find(keys); if (gridRow != null) { gridRow.ItemArray = _oneIssueDataTable.Rows[0].ItemArray; // will fire RowUpdated event } else { gridDataSource.Rows.Add(_oneIssueDataTable.Rows[0].ItemArray); //gridRow.ItemArray = _oneIssueDataTable.Rows[0].ItemArray; //gridDataSource.Rows.Add(gridRow); // will fire TableNewRow event } } _oneIssueDataTable.Clear(); btnSave.Visible = false; btnCancel.Visible = false; btnNew.Visible = true; } else { StatusMessage.Text = issuesRow.RowError; } }
private void btnNew_Click(object sender, EventArgs e) { _oneIssueDataTable.Clear(); IssuesCD.IssuesRow dr = _oneIssueDataTable.NewIssuesRow(); _oneIssueDataTable.Rows.Add(dr); _bsIssue.DataSource = _oneIssueDataTable; btnSave.Visible = true; btnCancel.Visible = true; btnNew.Visible = false; }
//private void Grid_EventHandlers_Remove() //{ // try { Grid.GridDoubleClick -= Grid_DoubleClick; } catch { } // try { Grid.DataGridView.CellValidating -= Grid_CellValidating; } catch { } // try { Grid.DataGridView.CellEndEdit -= Grid_CellEndEdit; } catch { } // // TODO add custom GRID event handlers //} private void Grid_DoubleClick(object sender, GridDoubleClickEventArgs e) { _oneIssueDataTable.Clear(); IssuesCD.IssuesRow dr = _oneIssueDataTable.NewIssuesRow(); dr.ItemArray = e.Row.ItemArray; _oneIssueDataTable.Rows.Add(dr); _bsIssue.DataSource = _oneIssueDataTable; _oneIssueDataTable.AcceptChanges(); btnSave.Visible = true; btnCancel.Visible = true; btnNew.Visible = false; }