private void btn_Ordertype_Up_Click(object sender, EventArgs e) { if (Grid_Order_Type_Abs.Rows.Count > 0) { int rowscount = Grid_Order_Type_Abs.Rows.Count; int index = Grid_Order_Type_Abs.SelectedCells[0].OwningRow.Index; if (index == 0) { return; } DataGridViewRowCollection rows = Grid_Order_Type_Abs.Rows; // remove the previous row and add it behind the selected row. DataGridViewRow prevRow = rows[index - 1];; rows.Remove(prevRow); prevRow.Frozen = false; rows.Insert(index, prevRow); Grid_Order_Type_Abs.ClearSelection(); Grid_Order_Type_Abs.Rows[index - 1].Selected = true; Grid_Order_Type_Abs.FirstDisplayedScrollingRowIndex = Grid_Order_Type_Abs.SelectedRows[0].Index; } }
private void btn_Order_Type_Down_Click(object sender, EventArgs e) { if (Grid_Order_Type_Abs.Rows.Count > 0) { int rowCount = Grid_Order_Type_Abs.Rows.Count; int index = Grid_Order_Type_Abs.SelectedCells[0].OwningRow.Index; if (index == (rowCount - 1)) // include the header row { return; } DataGridViewRowCollection rows = Grid_Order_Type_Abs.Rows; // remove the next row and add it in front of the selected row. DataGridViewRow nextRow = rows[index + 1]; rows.Remove(nextRow); nextRow.Frozen = false; rows.Insert(index, nextRow); Grid_Order_Type_Abs.ClearSelection(); Grid_Order_Type_Abs.Rows[index + 1].Selected = true; Grid_Order_Type_Abs.FirstDisplayedScrollingRowIndex = Grid_Order_Type_Abs.SelectedRows[0].Index; } }
private bool Validate_Copy() { if (Grid_List.Rows.Count <= 0) { MessageBox.Show("Requried List"); return(false); } if (Grid_Order_Type_Abs.Rows.Count <= 0) { MessageBox.Show("Requried Order Type Abbrivation"); return(false); } for (int u = 0; u < Grid_User_Copy_List.Rows.Count; u++) { bool list = (bool)Grid_User_Copy_List[0, u].FormattedValue; if (list == true) { U_Check = 1; break; } else { U_Check = 0; } } for (int i = 0; i < Grid_List.Rows.Count; i++) { bool list = (bool)Grid_List[0, i].FormattedValue; if (list == true) { List_Check = 1; break; } else { List_Check = 0; } } for (int k = 0; k < Grid_Order_Type_Abs.Rows.Count; k++) { bool ordertype = (bool)Grid_Order_Type_Abs[0, k].FormattedValue; if (ordertype == true) { Order_Type_Check = 1; break; } else { Order_Type_Check = 0; } } if (U_Check == 0) { MessageBox.Show("Select atleast any one User to Copy"); Grd_User_List.Focus(); return(false); } if (List_Check == 0) { MessageBox.Show("Select atleast any one List"); Grid_List.Focus(); return(false); } if (Order_Type_Check == 0) { MessageBox.Show("Select atleast any one Order Type Abbrivation"); Grid_Order_Type_Abs.Focus(); return(false); } return(true); }