コード例 #1
0
        private void ButtonForRemoveRow_Click(object sender, RoutedEventArgs e)
        {
            OperationInModifingTable();

            DataView dataView;

            if (Controller.GetController().DGContent == DataGridContent.ContentGrid)
            {
                dataView = DataGridForContent.ItemsSource as DataView;

                for (int i = dataView.Count - 1; i >= 0; i--)
                {
                    var row = DataGridForContent.GetRow(i);
                    if (row.IsSelected)
                    {
                        dataView.Delete(i);
                    }
                }
            }
            else
            {
                dataView = DataGridForSchema.ItemsSource as DataView;

                for (int i = dataView.Count - 1; i >= 0; i--)
                {
                    var row = DataGridForSchema.GetRow(i);
                    if (row.IsSelected)
                    {
                        dataView.Delete(i);
                    }
                }
            }
        }
コード例 #2
0
        private void OperationAfterModifingTable()
        {
            GridForModifyTableAction.Visibility = Visibility.Collapsed;
            DBTreeView.IsEnabled             = true;
            ToolBarMain.IsEnabled            = true;
            GridForAddAndRemoveRow.IsEnabled = true;
            ButtonForRemoveRow.IsEnabled     = false;

            if (Controller.GetController().DGContent == DataGridContent.ContentGrid)
            {
                DataGridForContent.CellEditEnding += DataGrid_CellEditEnding;
                var dataView = DataGridForContent.ItemsSource as DataView;
                for (int i = 0; i < dataView.Count; i++)
                {
                    var row = DataGridForContent.ItemContainerGenerator.ContainerFromIndex(i) as DataGridRow;
                    if (row == null)
                    {
                        DataGridForContent.UpdateLayout();
                        DataGridForContent.ScrollIntoView(DataGridForContent.Items[i]);
                        row = DataGridForContent.ItemContainerGenerator.ContainerFromIndex(i) as DataGridRow;
                    }
                    row.IsEnabled  = true;
                    row.IsSelected = false;
                }
            }
            else
            {
                DataGridForSchema.CellEditEnding += DataGrid_CellEditEnding;
                var dataView = DataGridForSchema.ItemsSource as DataView;
                for (int i = 0; i < dataView.Count; i++)
                {
                    var row = DataGridForSchema.ItemContainerGenerator.ContainerFromIndex(i) as DataGridRow;
                    if (row == null)
                    {
                        DataGridForSchema.UpdateLayout();
                        DataGridForSchema.ScrollIntoView(DataGridForSchema.Items[i]);
                        row = DataGridForSchema.ItemContainerGenerator.ContainerFromIndex(i) as DataGridRow;
                    }

                    row.IsEnabled  = true;
                    row.IsSelected = false;
                }
            }
        }
コード例 #3
0
        private void ButtonForAddRow_Click(object sender, RoutedEventArgs e)
        {
            OperationInModifingTable();

            if (Controller.GetController().DGContent == DataGridContent.ContentGrid)
            {
                DataView dataView = DataGridForContent.ItemsSource as DataView;
                dataView.AddNew();

                for (int i = 0; i < dataView.Count - 1; i++)
                {
                    var row = DataGridForContent.GetRow(i);
                    row.IsEnabled  = false;
                    row.IsSelected = false;
                }

                var newRow = DataGridForContent.GetRow(dataView.Count - 1);
                newRow.IsSelected = true;
            }

            else
            {
                DataView dataView = DataGridForSchema.ItemsSource as DataView;
                dataView.AddNew();

                for (int i = 0; i < dataView.Count - 1; i++)
                {
                    DataGridRow row = DataGridForSchema.GetRow(i);
                    row.IsEnabled  = false;
                    row.IsSelected = false;
                }

                DataGridRow newRow = DataGridForSchema.GetRow(dataView.Count - 1);
                newRow.IsSelected = true;
            }
        }