//-------------------------------------------------------------------------------------------
        // Events handlers
        //-------------------------------------------------------------------------------------------
        void _bs_PositionChanged(object sender, EventArgs e)
        {
            if (_internalPositionChanged)
            {
                _internalPositionChanged = false;
                return;
            }
            if (_bs.Position >= 0 && this.Rows.Count > _bs.Position)
            {
                TreeDataGridViewRow row = this.Rows[_bs.Position] as TreeDataGridViewRow;
                for (int i = 0; i < _bs.List.Count; i++)
                {
                    DataRowView drv = _bs.List[i] as DataRowView;
                    if (row.DataBoundItem != null && row.DataBoundItem.Equals(drv.Row))
                    {
                        for (int j = 0; j < _bs.List.Count; j++)
                        {
                            this.SetSelectedRowCore(j, false);
                        }

                        this.SetSelectedRowCore(i, true);
                        return;
                    }
                }
            }
        }
        public void ExpandRow(int Index)
        {
            TreeDataGridViewRow row = this.Rows[Index] as TreeDataGridViewRow;

            if (row != null && row.ParentRow != null)
            {
                ExpandRow(row.ParentRow.Index);
            }
        }
 private void TreeDataGrid_CellMouseClick_1(object sender, DataGridViewCellMouseEventArgs e)
 {
     if (e.Clicks == 1 && e.RowIndex >= 0)
     {
         TreeDataGridViewRow row = this.Rows[e.RowIndex] as TreeDataGridViewRow;
         for (int i = 0; i < _bs.List.Count; i++)
         {
             DataRowView drv = _bs.List[i] as DataRowView;
             if (row.DataBoundItem.Equals(drv.Row))
             {
                 _internalPositionChanged = true;
                 _bs.Position             = i;
                 return;
             }
         }
     }
 }
Beispiel #4
0
 protected override void OnMouseDoubleClick(DataGridViewCellMouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         //  if (offset.Contains(e.Location))
         TreeDataGridViewRow tr = this.OwningRow as TreeDataGridViewRow;
         if (tr.Expanded)
         {
             tr.Collupse();
         }
         else
         {
             tr.Expand();
         }
     }
     else
     {
         base.OnMouseDoubleClick(e);
     }
 }
        private void InsertDataGridRows(List <_TreeNode> l, TreeDataGridViewRow parent)
        {
            foreach (_TreeNode tn in l)
            {
                int index = this.Rows.Add(this.RowTemplate.Clone());
                TreeDataGridViewRow insertedRow = this.Rows[index] as TreeDataGridViewRow;
                insertedRow.DataBoundItem = (tn.Node as DataRowView).Row;
                insertedRow.SetValues((tn.Node as DataRowView).Row.ItemArray);
                insertedRow.ParentRow = parent;
                if (parent != null)
                {
                    insertedRow.Level = parent.Level + 1;
                    parent.Child.Add(insertedRow);
                }

                if (insertedRow.Level > 0)
                {
                    insertedRow.Visible = false;
                }

                InsertDataGridRows(tn.Child, insertedRow);
            }
        }