示例#1
0
        /// <summary>
        /// Create a OLVListItem for given row index
        /// </summary>
        /// <param name="itemIndex">The index of the row that is needed</param>
        /// <returns>An OLVListItem</returns>
        public virtual OLVListItem MakeListViewItem(int itemIndex)
        {
            var o = GetModelObject(itemIndex);

            if (o == null)
            {
                return(null);
            }

            var olvi = new OLVListItem(o);

            FillInValues(olvi, olvi.RowObject);
            if (UseAlternatingBackColors)
            {
                if (View == View.Details && itemIndex % 2 == 1)
                {
                    olvi.BackColor = AlternateRowBackColorOrDefault;
                }
                else
                {
                    olvi.BackColor = BackColor;
                }

                CorrectSubItemColors(olvi);
            }

            SetSubItemImages(itemIndex, olvi);
            return(olvi);
        }
示例#2
0
 /// <summary>
 /// Create an event args
 /// </summary>
 /// <param name="column"></param>
 /// <param name="control"></param>
 /// <param name="r"></param>
 /// <param name="item"></param>
 /// <param name="subItemIndex"></param>
 public CellEditEventArgs(OLVColumn column, Control control, Rectangle r, OLVListItem item, int subItemIndex)
 {
     this.Control      = control;
     this.column       = column;
     this.cellBounds   = r;
     this.listViewItem = item;
     this.rowObject    = item.RowObject;
     this.subItemIndex = subItemIndex;
     this.value        = column.GetValue(item.RowObject);
 }
示例#3
0
        /// <summary>
        /// Handle the given mouse down event as a possible attempt to expand/collapse
        /// a row. Return true if the event was handled.
        /// </summary>
        /// <param name="olvItem">The olv item.</param>
        /// <param name="x">The x.</param>
        /// <param name="y">The y.</param>
        /// <returns></returns>
        protected virtual bool HandlePossibleExpandClick(OLVListItem olvItem, int x, int y)
        {
            Branch br = TreeModel.GetBranch(olvItem.RowObject);

            if (br == null || !br.CanExpand)
            {
                return(false);
            }

            // Calculate if they clicked on the expand/collapse icon. This icon
            // appears before the icon of the item.
            int smallImageWidth = 16;

            if (SmallImageList != null)
            {
                smallImageWidth = SmallImageList.ImageSize.Width;
            }

            Rectangle r = GetItemRect(olvItem.Index, ItemBoundsPortion.Icon);

            if (r.Width == 0)
            {
                // If GetItemRect() returns a  0-width rectangle, there are no images,
                // but we still need to check if the click was before the text.
                r.X    += (br.Level - 1) * (smallImageWidth + 2);
                r.Width = smallImageWidth;
            }
            else
            {
                r.X -= (smallImageWidth + 2);
            }

            // Take the checkboxes into account
            if (CheckBoxes)
            {
                r.X -= (smallImageWidth + 2);
            }

            if (!r.Contains(x, y))
            {
                return(false);
            }

            PossibleFinishCellEditing();
            ToggleExpansion(olvItem.RowObject);
            return(true);
        }
示例#4
0
        /// <summary>
        /// Create a OLVListItem for given row index
        /// </summary>
        /// <param name="itemIndex">The index of the row that is needed</param>
        /// <returns>An OLVListItem</returns>
        /// <remarks>This differs from the base method by also setting up the IndentCount property.</remarks>
        public override OLVListItem MakeListViewItem(int itemIndex)
        {
            OLVListItem olvItem = base.MakeListViewItem(itemIndex);

            if (olvItem == null)
            {
                return(null);
            }

            Branch br = TreeModel.GetBranch(olvItem.RowObject);

            if (br != null)
            {
                olvItem.IndentCount = br.Level;
            }
            return(olvItem);
        }
示例#5
0
 /// <summary>
 /// Refresh the given item in the list
 /// </summary>
 /// <param name="olvi">The item to refresh</param>
 public override void RefreshItem(OLVListItem olvi)
 {
     ClearCachedInfo();
     RedrawItems(olvi.Index, olvi.Index, false);
 }