Exemplo n.º 1
0
        public void ShowEditControl()
        {
            if (_treelistview.FocusedItem == null)
            {
                return;
            }
            ListViewItem item = (ListViewItem)_treelistview.EditedItem.Item;
            Rectangle    rec  = _treelistview.EditedItem.ColumnIndex > 0 ?
                                _treelistview.GetSubItemRect(item.Index, _treelistview.EditedItem.ColumnIndex) :
                                _treelistview.GetItemRect(item.Index, ItemBoundsPortion.Label);

            _editor.Size     = rec.Size;
            _editor.Location = rec.Location;
            _editor.Top--;
            _editor.Show();
            _editor.Text = item.SubItems[_treelistview.EditedItem.ColumnIndex].Text;
            _editor.Focus();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Retrieves the specified portion of the bounding rectangle for the item
        /// </summary>
        /// <param name="portion">One of the TreeListViewItemBoundsPortion values that represents a portion of the item for which to retrieve the bounding rectangle</param>
        /// <returns>A Rectangle that represents the bounding rectangle for the specified portion of the item</returns>
        public Rectangle GetBounds(TreeListViewItemBoundsPortion portion)
        {
            switch ((int)portion)
            {
            case (int)TreeListViewItemBoundsPortion.PlusMinus:
                if (TreeListView == null)
                {
                    throw (new Exception("This item is not associated with a TreeListView control"));
                }
                Point pos      = base.GetBounds(ItemBoundsPortion.Entire).Location;
                Point position = new Point(
                    Level * SystemInformation.SmallIconSize.Width + 1 + pos.X,
                    TreeListView.GetItemRect(Index, ItemBoundsPortion.Entire).Top + 1);
                return(new Rectangle(position, TreeListView.ShowPlusMinus ? SystemInformation.SmallIconSize : new Size(0, 0)));

            default:
                ItemBoundsPortion lviPortion = (ItemBoundsPortion)(int)portion;
                return(base.GetBounds(lviPortion));
            }
        }