Ejemplo n.º 1
0
 /// <summary>
 /// 给控件赋值
 /// </summary>
 /// <param name="childItem"></param>
 /// <param name="rowIndex"></param>
 private void GetNewInfo(MyPanelChild childItem, int rowIndex)
 {
     if (rowIndex >= 0 && rowIndex <= itemList.Count - 1)
     {
         for (int i = 0; i < itemList.Count; i++)
         {
             if (itemList[i].RowIndex == rowIndex)
             {
                 PanelItem item = itemList[i];
                 childItem.IsSelected = item.IsSelected;
                 childItem.DataRow = item.DataRow;
                 childItem.Height = item.Height;
                 childItem.RowIndex = rowIndex;
                 break;
             }
         }
     }
 }
        /// <summary>
        /// 添加控件
        /// </summary>
        /// <param name="item"></param>
        private void AddControl(MyPanelChild item)
        {
            item.DefaultColor = defaultColor;
            item.MouseEnterColor = mouseEnterColor;
            item.SelectedColor = selectedColor;
            item.Width = this.pnlContent.Width;
            item.Anchor = (AnchorStyles)(AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top);
            if (controlList.Count == 0)
            {
                item.Top = 0;
            }
            else
            {
                MyPanelChild lastItem = controlList.First(t => t.Value == item.RowIndex - 1).Key;
                item.Top = lastItem.Top + lastItem.Height;
            }

            controlList.Add(item, item.RowIndex);
            this.pnlContent.Controls.Add(item);
            item.MouseClick += item_MouseClick;
            item.MouseEnter += Item_MouseEnter;
            item.MouseLeave += Item_MouseLeave;
            item.MouseMove += Item_MouseMove;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 添加控件
        /// </summary>
        /// <param name="item"></param>
        private void AddControl(MyPanelChild item)
        {
            item.DefaultColor = defaultColor;
            item.MouseEnterColor = mouseEnterColor;
            item.SelectedColor = selectedColor;
            item.Width = this.pnlContent.Width;
            item.Anchor = (AnchorStyles)(AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top);
            item.Top = item.Height * item.RowIndex - myVScrollBar1.Value;

            controlList.Add(item, item.RowIndex);
            this.pnlContent.Controls.Add(item);
            item.MouseClick += item_MouseClick;
            item.MouseEnter += Item_MouseEnter;
            item.MouseLeave += Item_MouseLeave;
            item.MouseMove += Item_MouseMove;
        }
        /// <summary>
        /// 添加控件
        /// </summary>
        /// <param name="item"></param>
        private void AddControl(MyPanelChild item)
        {
            item.DefaultColor = defaultColor;
            item.MouseEnterColor = mouseEnterColor;
            item.SelectedColor = selectedColor;
            item.Width = this.pnlContent.Width;
            item.Anchor = (AnchorStyles)(AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top);
            if (controlList.Count == 0 || item.RowIndex == 0)
            {
                item.Top = 0;
            }
            else
            {
                KeyValuePair<MyPanelChild, int> find = controlList.FirstOrDefault(t => t.Value == item.RowIndex - 1);
                if (find.Key != null)
                {
                    item.Top = find.Key.Top + find.Key.Height;
                }
                else
                {
                    find = controlList.FirstOrDefault(t => t.Value == item.RowIndex + 1);
                    if (find.Key != null)
                    {
                        item.Top = find.Key.Top - item.Height;
                    }
                }
            }

            controlList.Add(item, item.RowIndex);
            this.pnlContent.Controls.Add(item);
            item.MouseClick += item_MouseClick;
            item.MouseEnter += Item_MouseEnter;
            item.MouseLeave += Item_MouseLeave;
            item.MouseMove += Item_MouseMove;
        }