コード例 #1
0
 private void appbar_arrow_right_Click(object sender, RoutedEventArgs e)
 {
     if (ForSelect.SelectedItems.Count != 0)
     {
         string p        = ForSelect.SelectedItem.ToString();
         bool   findSame = false;
         foreach (var plane_type in AllPlaneTypes)
         {
             if (plane_type.type == p)
             {
                 findSame = true;
             }
         }
         if (findSame)
         {
             MessageBox.Show("机型不可重复!", "错误提示");
         }
         else if (ForSelect1.SelectedIndex == -1 || ForSelect2.SelectedIndex == -1)
         {
             MessageBox.Show("请设置引导线和停止线", "错误提示");
         }
         else
         {
             char[] tempc = ForSelect2.SelectedValue.ToString().ToCharArray();
             PlaneTypeDataGrid.ItemsSource = null;
             AllPlaneTypes.Add(new PlaneType(p, Convert.ToInt32(ForSelect1.SelectedValue), ForSelect2.SelectedValue.ToString()));
             PlaneTypeDataGrid.ItemsSource = AllPlaneTypes;
             PlaneTypeDataGrid.Focus();
             PlaneTypeDataGrid.ScrollIntoView(PlaneTypeDataGrid.Items[PlaneTypeDataGrid.Items.Count - 1]);
             PlaneTypeDataGrid.CurrentCell  = new DataGridCellInfo(PlaneTypeDataGrid.Items[PlaneTypeDataGrid.Items.Count - 1], PlaneTypeDataGrid.Columns[0]);
             PlaneTypeDataGrid.SelectedItem = PlaneTypeDataGrid.Items[PlaneTypeDataGrid.Items.Count - 1];
             PlaneTypeDataGrid.BeginEdit();
         }
     }
 }
コード例 #2
0
        void SetEditStatusThread(object focus_item)
        {
            Thread.Sleep(300);
            SetEditStatus st = new SetEditStatus(delegate(object item)
            {
                PlaneTypeDataGrid.Focus();
                PlaneTypeDataGrid.SelectedCells.Clear();
                PlaneTypeDataGrid.ScrollIntoView(item);
                PlaneTypeDataGrid.CurrentCell  = new DataGridCellInfo(item, PlaneTypeDataGrid.Columns[0]);
                PlaneTypeDataGrid.SelectedItem = item;
                PlaneTypeDataGrid.BeginEdit();
                PlaneTypeDataGrid.CellEditEnding += PlaneTypeDataGrid_CellEditEnding;
            });

            Dispatcher.Invoke(st, focus_item);
        }