private void open_Click(object sender, RoutedEventArgs e) { FileAccess.OpenDialog(); if (Global.FileFound == true) // Get the selected file name and display in a TextBox { if (dataGrid.Items.Count != 0) //check if datagrid currently has any data { this.dataGrid.ItemsSource = null; //delete contents of datagrid GridFGV.grid.Clear(); //remove contents of GridFGV accessor } string[] lines; FileAccess.ReadFile(Global.Filename, out lines); // Open document Global.Filesize = lines.Count(); List cmds = new List(); int i = 0; foreach (string line in lines) { string[] entry; entry = line.Split(','); //convert comma seperated string to 1-d array if (entry.Count() > 4) //check that the file has correct number of columns { textBox.Text = "Invalid file: number of columns not compatible"; break; } Grid_List.Add(entry[0], entry[1], entry[2]); this.dataGrid.ItemsSource = GridFGV.grid; i++; } } }
}// found online private void remove_Click(object sender, RoutedEventArgs e) { //ContextMenu cm = this.FindResource("RemoveButton") as ContextMenu; //cm.PlacementTarget = sender as Button; //cm.IsOpen = true; Grid_List.Remove(dataGrid.SelectedIndex); // this.dataGrid.ItemsSource = null; this.dataGrid.ItemsSource = GridFGV.grid; Global.Filesize = Global.Filesize - 1; }
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); }
private void add_Click(object sender, RoutedEventArgs e) { Grid_List.Add(index.Text, command.Text, comment.Text); this.Close(); }