c#实现可折叠导航栏Word文档下载推荐.docx
- 文档编号:17957974
- 上传时间:2022-12-12
- 格式:DOCX
- 页数:27
- 大小:42.47KB
c#实现可折叠导航栏Word文档下载推荐.docx
《c#实现可折叠导航栏Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《c#实现可折叠导航栏Word文档下载推荐.docx(27页珍藏版)》请在冰豆网上搜索。
System.Windows.Forms;
11.
12.namespace
WindowsApplication1
13.{
14.
public
partial
class
NavBar
:
Panel
15.
{
16.
private
NavGroupCollection
_groups;
17.
Groups
18.
19.
get
return
this._groups;
}
20.
21.
NavGroup
this[int
index]
22.
23.
24.
25.
if
(index
>
-1)
26.
this._groups[index];
27.
else
28.
null;
29.
30.
31.
int
_selectedIndex
=
-1;
32.
///
<
summary>
33.
选择组的索引
34.
/summary>
35.
[DefaultValue(-1)]
36.
SelectedIndex
37.
38.
this._selectedIndex;
39.
set
40.
41.
this._selectedIndex
value;
42.
this.SelectGroup(value);
43.
44.
45.
_groupSpace
20;
46.
47.
Group间距
48.
49.
GroupSpace
50.
51.
this._groupSpace;
52.
this._groupSpace
53.
54.
_groupMargin
5;
55.
56.
Group边距
57.
58.
GroupMargin
59.
60.
this._groupMargin;
61.
this._groupMargin
62.
63.
ImageList
_smallImageList;
64.
65.
设置图像列表
66.
67.
SmallImageList
68.
69.
this._smallImageList;
70.
this._smallImageList
71.
72.
NavBar()
73.
74.
InitializeComponent();
75.
76.
this.BackColor
Color.FromArgb(112,
140,
225);
77.
this._groups
new
NavGroupCollection(this);
78.
this.AutoScroll
true;
79.
80.
81.
根据添加的项,布局
82.
83.
param
name="
item"
/param>
84.
void
SetLayOut(NavGroup
item)
85.
86.
this.SuspendLayout();
87.
this.Controls.Add(item);
88.
(this._groups.Count
==
0)
89.
90.
item.Top
10;
91.
92.
93.
94.
this[this._groups.Count
-
1].Bottom
+
this.GroupSpace;
95.
96.
item.Width
this.Width
2
*
this.GroupMargin;
97.
item.Left
(this.Width
item.Width)
/
2;
98.
item.Height
item.TitleHeight;
99.
this.ResumeLayout();
100.
//item.Anchor
AnchorStyles.Top
|
AnchorStyles.Left
AnchorStyles.Right;
101.
102.
103.
重新布局组件
104.
105.
SetLayOut()
106.
107.
for
(int
i
0;
this._groups.Count;
i++)
108.
109.
(i
110.
this._groups[i].Top
111.
112.
113.
this._groups[i
114.
this._groups[i].GroupIndex
i;
115.
116.
117.
118.
119.
添加分组
120.
121.
returns>
/returns>
122.
AddGroup()
123.
124.
this._groups.Add();
125.
this._groups[this._groups.Count
1];
126.
127.
128.
删除分组
129.
130.
131.
RemoveGroup(NavGroup
132.
133.
item.GroupIndex;
134.
this._groups.Remove(item);
135.
this.Controls.Remove(item);
136.
this.SetLayOut();
137.
138.
139.
删除指定索引的分组
140.
141.
index"
142.
RemoveGroupAt(int
index)
143.
144.
this.Controls.Remove(this._groups[index]);
145.
this._groups.RemoveAt(index);
146.
147.
148.
149.
选中指定索引的分组
150.
151.
152.
SelectGroup(int
153.
154.
foreach
(NavGroup
g
in
this._groups)
155.
156.
(g.GroupIndex
this._selectedIndex)
continue;
157.
g.IsSelected
false;
158.
159.
160.
161.
protected
override
OnPaint(PaintEventArgs
e)
162.
163.
base.OnPaint(e);
164.
165.
166.}
NavGroup.cs
System.Drawing.Drawing2D;
10.
11.namespace
12.{
13.
Control
Rectangle
_titleRectangle;
_ownerBar;
NavBarButton
_button;
NavBarItemCollection
_items;
Items
this._items;
this._items
NavBarItem
this._items[index];
NavGroupState
_groupState
NavGroupState.expand;
组的状态
GroupState
this._groupState;
this._groupState
this.SetGroupState(value);
_groupIndex;
组索引
GroupIndex
this._groupIndex;
this._groupIndex
_titleHeight
标题高度
TitleHeight
this._titleHeight;
this._titleHeight
this.SetTitleRectangle();
string
_title;
标题
Title
this._title;
this._title
Color
_titleStartColor
Color.White;
标题渐变开始色
TitleStartColor
this._titleStartColor;
this._titleStartColor
_titleEndColor
Color.FromArgb(199,
211,
247);
标题渐变结束色
TitleEndColor
this._titleEndColor;
this._titleEndColor
_itemSpace
Item间距
ItempSpace
this._itemSpace;
this._itemSpace
p
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- c# 实现 可折叠 导航
![提示](https://static.bdocx.com/images/bang_tan.gif)