Ejemplo n.º 1
0
        // End of (mostly copied) drag-drop functions

        private void InsertInOrder(TreeNode Parent, TreeNode Child)
        {
            int Idx;
            CostCentreNodeDetails ChildTag = (CostCentreNodeDetails)Child.Tag;

            for (Idx = 0; Idx < Parent.Nodes.Count; Idx++)
            {
                if (Parent.Nodes[Idx].Text.CompareTo(Child.Text) > 0)
                {
                    break;
                }
            }

            if (Idx == Parent.Nodes.Count)
            {
                Parent.Nodes.Add(Child);
            }
            else
            {
                Parent.Nodes.Insert(Idx, Child);
            }

            if (!FDuringInitialisation)
            {
                FParentForm.SetSelectedCostCentre(ChildTag);
            }
        }
        void Selection_SelectionChanged(object sender, SourceGrid.RangeRegionChangedEventArgs e)
        {
            if (FParentForm.FIAmUpdating == 0)
            {
                int         previousRowId = FPrevRowChangedRow;
                int         newRowId      = grdCostCentres.Selection.ActivePosition.Row;
                DataRowView rowView       = (DataRowView)grdCostCentres.Rows.IndexToDataSourceRow(newRowId);

                if (rowView == null)
                {
                    FPreviouslySelectedDetailRow = null;
                    FParentForm.SetSelectedCostCentre(null);
                    FParentForm.PopulateControlsAfterRowSelection();
                    Console.WriteLine("Selected row is NULL");
                }
                else
                {
                    FPreviouslySelectedDetailRow = rowView.Row;
                    String SelectedCostCentreCode = ((ACostCentreRow)rowView.Row).CostCentreCode;
                    FParentForm.SetSelectedCostCentreCode(SelectedCostCentreCode);

                    if (previousRowId == -1)
                    {
                        FParentForm.PopulateControlsAfterRowSelection();
                    }

                    Console.WriteLine("Row is {0}", FPreviouslySelectedDetailRow.ItemArray[1]);
                }

                FPrevRowChangedRow = newRowId;
            }
        }