Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
刘韬
/
HZH_Controls
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit ba589629
由
HZH
编写于
2019-08-12 10:43:00 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
datagridview绑定分页控件
1 个父辈
5f164a46
全部展开
显示空白字符变更
内嵌
并排
正在显示
17 个修改的文件
包含
236 行增加
和
77 行删除
HZH_Controls/HZH_Controls/Controls/ComboBox/UCComboBox.cs
HZH_Controls/HZH_Controls/Controls/DataGridView/DataGridViewCellEventArgs.cs
HZH_Controls/HZH_Controls/Controls/DataGridView/DataGridViewCellEventHandler.cs
HZH_Controls/HZH_Controls/Controls/DataGridView/IDataGridViewRow.cs
HZH_Controls/HZH_Controls/Controls/DataGridView/UCDataGridView.Designer.cs
HZH_Controls/HZH_Controls/Controls/DataGridView/UCDataGridView.cs
HZH_Controls/HZH_Controls/Controls/DataGridView/UCDataGridViewRow.cs
HZH_Controls/HZH_Controls/Controls/List/IPageControl.cs
HZH_Controls/HZH_Controls/Controls/List/UCPagerControl.Designer.cs
HZH_Controls/HZH_Controls/Controls/List/UCPagerControl.cs
HZH_Controls/HZH_Controls/Controls/List/UCPagerControlBase.cs
HZH_Controls/HZH_Controls/Forms/FrmAnchor.cs
HZH_Controls/HZH_Controls/Forms/FrmTips.cs
HZH_Controls/HZH_Controls/HZH_Controls.csproj
HZH_Controls/Test/Form1.Designer.cs
HZH_Controls/Test/Form1.cs
HZH_Controls/Test/FrmTemp1Test.cs
HZH_Controls/HZH_Controls/Controls/ComboBox/UCComboBox.cs
查看文件 @
ba58962
...
...
@@ -335,6 +335,9 @@ namespace HZH_Controls.Controls
private
void
click_MouseDown
(
object
sender
,
MouseEventArgs
e
)
{
if
(
_frmAnchor
==
null
||
_frmAnchor
.
IsDisposed
||
_frmAnchor
.
Visible
==
false
)
{
if
(
this
.
Source
!=
null
&&
this
.
Source
.
Count
>
0
)
{
int
intRow
=
0
;
...
...
@@ -356,8 +359,8 @@ namespace HZH_Controls.Controls
int
intWidth
=
this
.
Width
/
intCom
;
if
(
intWidth
<
_ItemWidth
)
intWidth
=
_ItemWidth
;
Size
size
=
new
Size
(
intCom
*
intWidth
,
intRow
*
50
);
ucTime
.
Size
=
size
;
Size
size
=
new
Size
(
intCom
*
intWidth
,
intRow
*
50
);
ucTime
.
Size
=
size
;
ucTime
.
FirstEvent
=
true
;
ucTime
.
SelectSourceEvent
+=
ucTime_SelectSourceEvent
;
ucTime
.
Row
=
intRow
;
...
...
@@ -378,6 +381,11 @@ namespace HZH_Controls.Controls
}
}
else
{
_frmAnchor
.
Close
();
}
}
Forms
.
FrmAnchor
_frmAnchor
;
...
...
HZH_Controls/HZH_Controls/Controls/DataGridView/DataGridViewCellEventArgs.cs
查看文件 @
ba58962
...
...
@@ -6,7 +6,7 @@ using System.Windows.Forms;
namespace
HZH_Controls.Controls
{
public
class
DataGridView
Cell
EventArgs
:
EventArgs
public
class
DataGridViewEventArgs
:
EventArgs
{
public
Control
CellControl
{
get
;
set
;
}
public
int
CellIndex
{
get
;
set
;
}
...
...
HZH_Controls/HZH_Controls/Controls/DataGridView/DataGridViewCellEventHandler.cs
查看文件 @
ba58962
...
...
@@ -8,5 +8,5 @@ namespace HZH_Controls.Controls
{
[
Serializable
]
[
ComVisible
(
true
)]
public
delegate
void
DataGridView
CellEventHandler
(
object
sender
,
DataGridViewCell
EventArgs
e
);
public
delegate
void
DataGridView
EventHandler
(
object
sender
,
DataGridView
EventArgs
e
);
}
HZH_Controls/HZH_Controls/Controls/DataGridView/IDataGridViewRow.cs
查看文件 @
ba58962
...
...
@@ -11,15 +11,15 @@ namespace HZH_Controls.Controls
/// <summary>
/// CheckBox选中事件
/// </summary>
event
DataGridView
Cell
EventHandler
CheckBoxChangeEvent
;
event
DataGridViewEventHandler
CheckBoxChangeEvent
;
/// <summary>
/// 点击单元格事件
/// </summary>
event
DataGridView
Cell
EventHandler
CellClick
;
event
DataGridViewEventHandler
CellClick
;
/// <summary>
/// 数据源改变事件
/// </summary>
event
DataGridView
Cell
EventHandler
SourceChanged
;
event
DataGridViewEventHandler
SourceChanged
;
/// <summary>
/// 列参数,用于创建列数和宽度
/// </summary>
...
...
HZH_Controls/HZH_Controls/Controls/DataGridView/UCDataGridView.Designer.cs
查看文件 @
ba58962
...
...
@@ -32,6 +32,7 @@
this
.
panColumns
=
new
System
.
Windows
.
Forms
.
TableLayoutPanel
();
this
.
ucSplitLine_H1
=
new
HZH_Controls
.
Controls
.
UCSplitLine_H
();
this
.
panRow
=
new
System
.
Windows
.
Forms
.
Panel
();
this
.
panPage
=
new
System
.
Windows
.
Forms
.
Panel
();
this
.
panHead
.
SuspendLayout
();
this
.
SuspendLayout
();
//
...
...
@@ -74,14 +75,24 @@
this
.
panRow
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Fill
;
this
.
panRow
.
Location
=
new
System
.
Drawing
.
Point
(
0
,
40
);
this
.
panRow
.
Name
=
"panRow"
;
this
.
panRow
.
Size
=
new
System
.
Drawing
.
Size
(
1061
,
52
5
);
this
.
panRow
.
Size
=
new
System
.
Drawing
.
Size
(
1061
,
47
5
);
this
.
panRow
.
TabIndex
=
1
;
//
// panPage
//
this
.
panPage
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Bottom
;
this
.
panPage
.
Location
=
new
System
.
Drawing
.
Point
(
0
,
515
);
this
.
panPage
.
Name
=
"panPage"
;
this
.
panPage
.
Size
=
new
System
.
Drawing
.
Size
(
1061
,
50
);
this
.
panPage
.
TabIndex
=
0
;
this
.
panPage
.
Visible
=
false
;
//
// UCDataGridView
//
this
.
AutoScaleMode
=
System
.
Windows
.
Forms
.
AutoScaleMode
.
None
;
this
.
BackColor
=
System
.
Drawing
.
Color
.
White
;
this
.
Controls
.
Add
(
this
.
panRow
);
this
.
Controls
.
Add
(
this
.
panPage
);
this
.
Controls
.
Add
(
this
.
panHead
);
this
.
Name
=
"UCDataGridView"
;
this
.
Size
=
new
System
.
Drawing
.
Size
(
1061
,
565
);
...
...
@@ -97,6 +108,7 @@
private
System
.
Windows
.
Forms
.
TableLayoutPanel
panColumns
;
private
UCSplitLine_H
ucSplitLine_H1
;
private
System
.
Windows
.
Forms
.
Panel
panRow
;
private
System
.
Windows
.
Forms
.
Panel
panPage
;
}
}
HZH_Controls/HZH_Controls/Controls/DataGridView/UCDataGridView.cs
查看文件 @
ba58962
...
...
@@ -17,6 +17,7 @@ namespace HZH_Controls.Controls
/// <summary>
/// 标题字体
/// </summary>
[
Description
(
"标题字体"
),
Category
(
"自定义"
)]
public
Font
HeadFont
{
get
{
return
m_headFont
;
}
...
...
@@ -26,6 +27,7 @@ namespace HZH_Controls.Controls
/// <summary>
/// 标题字体颜色
/// </summary>
[
Description
(
"标题文字颜色"
),
Category
(
"自定义"
)]
public
Color
HeadTextColor
{
get
{
return
m_headTextColor
;
}
...
...
@@ -36,6 +38,7 @@ namespace HZH_Controls.Controls
/// <summary>
/// 是否显示标题
/// </summary>
[
Description
(
"是否显示标题"
),
Category
(
"自定义"
)]
public
bool
IsShowHead
{
get
{
return
m_isShowHead
;
}
...
...
@@ -43,12 +46,18 @@ namespace HZH_Controls.Controls
{
m_isShowHead
=
value
;
panHead
.
Visible
=
value
;
if
(
m_page
!=
null
)
{
ResetShowCount
();
m_page
.
PageSize
=
m_showCount
;
}
}
}
private
int
m_headHeight
=
40
;
/// <summary>
/// 标题高度
/// </summary>
[
Description
(
"标题高度"
),
Category
(
"自定义"
)]
public
int
HeadHeight
{
get
{
return
m_headHeight
;
}
...
...
@@ -63,6 +72,7 @@ namespace HZH_Controls.Controls
/// <summary>
/// 是否显示复选框
/// </summary>
[
Description
(
"是否显示选择框"
),
Category
(
"自定义"
)]
public
bool
IsShowCheckBox
{
get
{
return
m_isShowCheckBox
;
}
...
...
@@ -80,6 +90,7 @@ namespace HZH_Controls.Controls
/// <summary>
/// 行高
/// </summary>
[
Description
(
"数据行高"
),
Category
(
"自定义"
)]
public
int
RowHeight
{
get
{
return
m_rowHeight
;
}
...
...
@@ -90,15 +101,25 @@ namespace HZH_Controls.Controls
/// <summary>
///
/// </summary>
[
Description
(
"可显示个数"
),
Category
(
"自定义"
)]
public
int
ShowCount
{
get
{
return
m_showCount
;
}
private
set
{
m_showCount
=
value
;
if
(
m_page
!=
null
)
{
m_page
.
PageSize
=
value
;
}
}
}
private
List
<
DataGridViewColumnEntity
>
m_columns
;
/// <summary>
/// 列
/// </summary>
[
Description
(
"列"
),
Category
(
"自定义"
)]
public
List
<
DataGridViewColumnEntity
>
Columns
{
get
{
return
m_columns
;
}
...
...
@@ -109,11 +130,11 @@ namespace HZH_Controls.Controls
}
}
private
object
m_dataSource
;
/// <summary>
/// 数据源,支持列表或table,如果使用翻页控件,请使用翻页控件的DataSource
/// </summary>
[
Description
(
"数据源,支持列表或table,如果使用翻页控件,请使用翻页控件的DataSource"
),
Category
(
"自定义"
)]
public
object
DataSource
{
get
{
return
m_dataSource
;
}
...
...
@@ -137,6 +158,7 @@ namespace HZH_Controls.Controls
/// <summary>
/// 行元素类型,默认UCDataGridViewItem
/// </summary>
[
Description
(
"行控件类型,默认UCDataGridViewRow,如果不满足请自定义行控件实现接口IDataGridViewRow"
),
Category
(
"自定义"
)]
public
Type
RowType
{
get
{
return
m_rowType
;
}
...
...
@@ -151,6 +173,7 @@ namespace HZH_Controls.Controls
/// <summary>
/// 选中的节点
/// </summary>
[
Description
(
"选中行"
),
Category
(
"自定义"
)]
public
IDataGridViewRow
SelectRow
{
get
{
return
m_selectRow
;
}
...
...
@@ -161,6 +184,7 @@ namespace HZH_Controls.Controls
/// <summary>
/// 选中的行,如果显示CheckBox,则以CheckBox选中为准
/// </summary>
[
Description
(
"选中的行,如果显示CheckBox,则以CheckBox选中为准"
),
Category
(
"自定义"
)]
public
List
<
IDataGridViewRow
>
SelectRows
{
get
...
...
@@ -173,14 +197,53 @@ namespace HZH_Controls.Controls
return
new
List
<
IDataGridViewRow
>()
{
m_selectRow
};
}
}
private
UCPagerControlBase
m_page
=
null
;
/// <summary>
/// 翻页控件
/// </summary>
[
Description
(
"翻页控件,如果UCPagerControl不满足你的需求,请自定义翻页控件并继承UCPagerControlBase"
),
Category
(
"自定义"
)]
public
UCPagerControlBase
Page
{
get
{
return
m_page
;
}
set
{
if
(!
typeof
(
IPageControl
).
IsAssignableFrom
(
value
.
GetType
())
||
!
value
.
GetType
().
IsSubclassOf
(
typeof
(
UCPagerControlBase
)))
throw
new
Exception
(
"翻页控件没有继承UCPagerControlBase"
);
panPage
.
Visible
=
value
!=
null
;
m_page
=
value
;
if
(
value
!=
null
)
{
m_page
.
ShowSourceChanged
+=
page_ShowSourceChanged
;
m_page
.
Dock
=
DockStyle
.
Fill
;
this
.
panPage
.
Controls
.
Clear
();
this
.
panPage
.
Controls
.
Add
(
m_page
);
ResetShowCount
();
m_page
.
PageSize
=
ShowCount
;
this
.
DataSource
=
m_page
.
GetCurrentSource
();
}
else
{
m_page
=
null
;
}
}
}
void
page_ShowSourceChanged
(
object
currentSource
)
{
this
.
DataSource
=
currentSource
;
}
#
region
事件
[
Description
(
"选中标题选择框事件"
),
Category
(
"自定义"
)]
public
EventHandler
HeadCheckBoxChangeEvent
;
[
Description
(
"标题点击事件"
),
Category
(
"自定义"
)]
public
EventHandler
HeadColumnClickEvent
;
[
Description
(
"项点击事件"
),
Category
(
"自定义"
)]
public
event
DataGridView
Cell
EventHandler
ItemClick
;
public
event
DataGridViewEventHandler
ItemClick
;
[
Description
(
"数据源改变事件"
),
Category
(
"自定义"
)]
public
event
DataGridView
Cell
EventHandler
SourceChanged
;
public
event
DataGridViewEventHandler
SourceChanged
;
#
endregion
#
endregion
...
...
@@ -280,14 +343,16 @@ namespace HZH_Controls.Controls
{
if
(
DesignMode
)
{
return
;
}
m_showCount
=
this
.
Height
/
(
m_rowHeight
);
int
intCha
=
this
.
Height
%
(
m_rowHeight
);
m_rowHeight
+=
intCha
/
m_s
howCount
;
ShowCount
=
this
.
panRow
.
Height
/
(
m_rowHeight
);
int
intCha
=
this
.
panRow
.
Height
%
(
m_rowHeight
);
m_rowHeight
+=
intCha
/
S
howCount
;
}
#
endregion
#
region
公共函数
/// <summary>
/// 刷新数据
/// </summary>
public
void
ReloadSource
()
{
if
(
DesignMode
)
...
...
@@ -382,7 +447,7 @@ namespace HZH_Controls.Controls
}
if
(
lastItem
!=
null
&&
intSourceCount
==
m_showCount
)
{
lastItem
.
Height
=
this
.
Height
-
(
m_showCount
-
1
)
*
m_rowHeight
;
lastItem
.
Height
=
this
.
panRow
.
Height
-
(
m_showCount
-
1
)
*
m_rowHeight
;
}
}
}
...
...
@@ -393,7 +458,12 @@ namespace HZH_Controls.Controls
}
/// <summary>
/// 快捷键
/// </summary>
/// <param name="msg"></param>
/// <param name="keyData"></param>
/// <returns></returns>
protected
override
bool
ProcessCmdKey
(
ref
Message
msg
,
Keys
keyData
)
{
if
(
keyData
==
Keys
.
Up
)
...
...
@@ -423,7 +493,7 @@ namespace HZH_Controls.Controls
return
;
Control
c
=
null
;
c
=
(
Rows
[
0
]
as
Control
);
SetSelectRow
(
c
,
new
DataGridView
Cell
EventArgs
()
{
RowIndex
=
0
});
SetSelectRow
(
c
,
new
DataGridViewEventArgs
()
{
RowIndex
=
0
});
}
/// <summary>
/// 选中上一个
...
...
@@ -438,7 +508,7 @@ namespace HZH_Controls.Controls
if
(
index
-
1
>=
0
)
{
c
=
(
Rows
[
index
-
1
]
as
Control
);
SetSelectRow
(
c
,
new
DataGridView
Cell
EventArgs
()
{
RowIndex
=
index
-
1
});
SetSelectRow
(
c
,
new
DataGridViewEventArgs
()
{
RowIndex
=
index
-
1
});
}
}
/// <summary>
...
...
@@ -454,7 +524,7 @@ namespace HZH_Controls.Controls
if
(
index
+
1
<
Rows
.
Count
)
{
c
=
(
Rows
[
index
+
1
]
as
Control
);
SetSelectRow
(
c
,
new
DataGridView
Cell
EventArgs
()
{
RowIndex
=
index
+
1
});
SetSelectRow
(
c
,
new
DataGridViewEventArgs
()
{
RowIndex
=
index
+
1
});
}
}
/// <summary>
...
...
@@ -466,19 +536,22 @@ namespace HZH_Controls.Controls
return
;
Control
c
=
null
;
c
=
(
Rows
[
Rows
.
Count
-
1
]
as
Control
);
SetSelectRow
(
c
,
new
DataGridView
Cell
EventArgs
()
{
RowIndex
=
Rows
.
Count
-
1
});
SetSelectRow
(
c
,
new
DataGridViewEventArgs
()
{
RowIndex
=
Rows
.
Count
-
1
});
}
#
endregion
#
region
事件
void
RowSourceChanged
(
object
sender
,
DataGridView
Cell
EventArgs
e
)
void
RowSourceChanged
(
object
sender
,
DataGridViewEventArgs
e
)
{
if
(
SourceChanged
!=
null
)
SourceChanged
(
sender
,
e
);
}
private
void
SetSelectRow
(
Control
item
,
DataGridView
Cell
EventArgs
e
)
private
void
SetSelectRow
(
Control
item
,
DataGridViewEventArgs
e
)
{
try
{
ControlHelper
.
FreezeControl
(
this
,
true
);
if
(
item
==
null
)
return
;
if
(
item
.
Visible
==
false
)
...
...
@@ -497,7 +570,22 @@ namespace HZH_Controls.Controls
{
ItemClick
(
item
,
e
);
}
this
.
panRow
.
AutoScrollPosition
=
new
Point
(
0
,
item
.
Location
.
Y
);
if
(
this
.
panRow
.
Controls
.
Count
>
0
)
{
if
(
item
.
Location
.
Y
<
0
)
{
this
.
panRow
.
AutoScrollPosition
=
new
Point
(
0
,
Math
.
Abs
(
this
.
panRow
.
Controls
[
this
.
panRow
.
Controls
.
Count
-
1
].
Location
.
Y
)
+
item
.
Location
.
Y
);
}
else
if
(
item
.
Location
.
Y
+
m_rowHeight
>
this
.
panRow
.
Height
)
{
this
.
panRow
.
AutoScrollPosition
=
new
Point
(
0
,
Math
.
Abs
(
this
.
panRow
.
AutoScrollPosition
.
Y
)
+
item
.
Location
.
Y
-
this
.
panRow
.
Height
+
m_rowHeight
);
}
}
}
finally
{
ControlHelper
.
FreezeControl
(
this
,
false
);
}
}
private
void
UCDataGridView_Resize
(
object
sender
,
EventArgs
e
)
{
...
...
HZH_Controls/HZH_Controls/Controls/DataGridView/UCDataGridViewRow.cs
查看文件 @
ba58962
...
...
@@ -9,15 +9,16 @@ using System.Windows.Forms;
namespace
HZH_Controls.Controls
{
[
ToolboxItem
(
false
)]
public
partial
class
UCDataGridViewRow
:
UserControl
,
IDataGridViewRow
{
#
region
属性
public
event
DataGridView
Cell
EventHandler
CheckBoxChangeEvent
;
public
event
DataGridViewEventHandler
CheckBoxChangeEvent
;
public
event
DataGridView
Cell
EventHandler
CellClick
;
public
event
DataGridViewEventHandler
CellClick
;
public
event
DataGridView
Cell
EventHandler
SourceChanged
;
public
event
DataGridViewEventHandler
SourceChanged
;
public
List
<
DataGridViewColumnEntity
>
Columns
{
...
...
@@ -81,7 +82,7 @@ namespace HZH_Controls.Controls
{
if
(
CellClick
!=
null
)
{
CellClick
(
sender
,
new
DataGridView
Cell
EventArgs
()
CellClick
(
sender
,
new
DataGridViewEventArgs
()
{
CellControl
=
this
,
CellIndex
=
(
sender
as
Control
).
Tag
.
ToInt
()
...
...
@@ -134,7 +135,7 @@ namespace HZH_Controls.Controls
IsChecked
=
box
.
Checked
;
if
(
CheckBoxChangeEvent
!=
null
)
{
CheckBoxChangeEvent
(
a
,
new
DataGridView
Cell
EventArgs
()
CheckBoxChangeEvent
(
a
,
new
DataGridViewEventArgs
()
{
CellControl
=
box
,
CellIndex
=
0
...
...
HZH_Controls/HZH_Controls/Controls/List/IPageControl.cs
查看文件 @
ba58962
...
...
@@ -10,7 +10,7 @@ namespace HZH_Controls.Controls
/// <summary>
/// 数据源改变时发生
/// </summary>
event
PageControlEventHandler
ShowChanged
;
event
PageControlEventHandler
Show
Source
Changed
;
/// <summary>
/// 数据源
/// </summary>
...
...
HZH_Controls/HZH_Controls/Controls/List/UCPagerControl.Designer.cs
查看文件 @
ba58962
namespace
HZH_Controls.Controls
.List
namespace
HZH_Controls.Controls
{
partial
class
UCPagerControl
{
...
...
@@ -64,7 +64,6 @@
this
.
panel4
.
Name
=
"panel4"
;
this
.
panel4
.
Size
=
new
System
.
Drawing
.
Size
(
68
,
46
);
this
.
panel4
.
TabIndex
=
3
;
this
.
panel4
.
Visible
=
false
;
this
.
panel4
.
MouseDown
+=
new
System
.
Windows
.
Forms
.
MouseEventHandler
(
this
.
panel4_MouseDown
);
//
// panel3
...
...
@@ -75,7 +74,6 @@
this
.
panel3
.
Name
=
"panel3"
;
this
.
panel3
.
Size
=
new
System
.
Drawing
.
Size
(
68
,
46
);
this
.
panel3
.
TabIndex
=
2
;
this
.
panel3
.
Visible
=
false
;
this
.
panel3
.
MouseDown
+=
new
System
.
Windows
.
Forms
.
MouseEventHandler
(
this
.
panel3_MouseDown
);
//
// panel2
...
...
@@ -86,7 +84,6 @@
this
.
panel2
.
Name
=
"panel2"
;
this
.
panel2
.
Size
=
new
System
.
Drawing
.
Size
(
68
,
46
);
this
.
panel2
.
TabIndex
=
1
;
this
.
panel2
.
Visible
=
false
;
this
.
panel2
.
MouseDown
+=
new
System
.
Windows
.
Forms
.
MouseEventHandler
(
this
.
panel2_MouseDown
);
//
// panel1
...
...
@@ -97,7 +94,6 @@
this
.
panel1
.
Name
=
"panel1"
;
this
.
panel1
.
Size
=
new
System
.
Drawing
.
Size
(
68
,
46
);
this
.
panel1
.
TabIndex
=
0
;
this
.
panel1
.
Visible
=
false
;
this
.
panel1
.
MouseDown
+=
new
System
.
Windows
.
Forms
.
MouseEventHandler
(
this
.
panel1_MouseDown
);
//
// UCPagerControl
...
...
HZH_Controls/HZH_Controls/Controls/List/UCPagerControl.cs
查看文件 @
ba58962
...
...
@@ -7,8 +7,9 @@ using System.Linq;
using
System.Text
;
using
System.Windows.Forms
;
namespace
HZH_Controls.Controls
.List
namespace
HZH_Controls.Controls
{
[
ToolboxItem
(
true
)]
public
partial
class
UCPagerControl
:
UCPagerControlBase
{
public
UCPagerControl
()
...
...
HZH_Controls/HZH_Controls/Controls/List/UCPagerControlBase.cs
查看文件 @
ba58962
...
...
@@ -9,6 +9,7 @@ using System.Windows.Forms;
namespace
HZH_Controls.Controls
{
[
ToolboxItem
(
false
)]
public
class
UCPagerControlBase
:
UserControl
,
IPageControl
{
#
region
构造
...
...
@@ -39,9 +40,13 @@ namespace HZH_Controls.Controls
private
void
InitializeComponent
()
{
this
.
SuspendLayout
();
//
// UCPagerControlBase
//
this
.
AutoScaleMode
=
System
.
Windows
.
Forms
.
AutoScaleMode
.
None
;
this
.
Name
=
"UCPagerControlBase"
;
this
.
Size
=
new
System
.
Drawing
.
Size
(
304
,
58
);
this
.
Load
+=
new
System
.
EventHandler
(
this
.
UCPagerControlBase_Load
);
this
.
ResumeLayout
(
false
);
}
...
...
@@ -52,13 +57,14 @@ namespace HZH_Controls.Controls
/// <summary>
/// 关联的数据源
/// </summary>
public
List
<
object
>
DataSource
{
get
;
set
;
}
public
event
PageControlEventHandler
ShowChanged
;
public
virtual
List
<
object
>
DataSource
{
get
;
set
;
}
public
event
PageControlEventHandler
Show
Source
Changed
;
private
int
m_pageSize
=
1
;
/// <summary>
/// 每页显示数量
/// </summary>
public
int
PageSize
[
Description
(
"每页显示数量"
),
Category
(
"自定义"
)]
public
virtual
int
PageSize
{
get
{
return
m_pageSize
;
}
set
{
m_pageSize
=
value
;
}
...
...
@@ -67,7 +73,8 @@ namespace HZH_Controls.Controls
/// <summary>
/// 开始的下标
/// </summary>
public
int
StartIndex
[
Description
(
"开始的下标"
),
Category
(
"自定义"
)]
public
virtual
int
StartIndex
{
get
{
return
startIndex
;
}
set
...
...
@@ -83,18 +90,38 @@ namespace HZH_Controls.Controls
{
InitializeComponent
();
}
public
void
FirstPage
()
private
void
UCPagerControlBase_Load
(
object
sender
,
EventArgs
e
)
{
if
(
DataSource
==
null
)
ShowBtn
(
false
,
false
);
else
{
ShowBtn
(
false
,
DataSource
.
Count
>
PageSize
);
}
}
/// <summary>
/// 第一页
/// </summary>
public
virtual
void
FirstPage
()
{
if
(
DataSource
==
null
)
return
;
startIndex
=
0
;
var
s
=
GetCurrentSource
();
if
(
ShowChanged
!=
null
)
if
(
Show
Source
Changed
!=
null
)
{
ShowChanged
(
s
);
Show
Source
Changed
(
s
);
}
}
public
void
PreviousPage
()
/// <summary>
/// 上一页
/// </summary>
public
virtual
void
PreviousPage
()
{
if
(
DataSource
==
null
)
return
;
if
(
startIndex
==
0
)
return
;
startIndex
-=
m_pageSize
;
...
...
@@ -102,13 +129,18 @@ namespace HZH_Controls.Controls
startIndex
=
0
;
var
s
=
GetCurrentSource
();
if
(
ShowChanged
!=
null
)
if
(
Show
Source
Changed
!=
null
)
{
ShowChanged
(
s
);
Show
Source
Changed
(
s
);
}
}
public
void
NextPage
()
/// <summary>
/// 下一页
/// </summary>
public
virtual
void
NextPage
()
{
if
(
DataSource
==
null
)
return
;
if
(
startIndex
+
m_pageSize
>=
DataSource
.
Count
)
{
return
;
...
...
@@ -118,38 +150,47 @@ namespace HZH_Controls.Controls
startIndex
=
0
;
var
s
=
GetCurrentSource
();
if
(
ShowChanged
!=
null
)
if
(
Show
Source
Changed
!=
null
)
{
ShowChanged
(
s
);
Show
Source
Changed
(
s
);
}
}
public
void
EndPage
()
/// <summary>
/// 最后一页
/// </summary>
public
virtual
void
EndPage
()
{
startIndex
=
DataSource
.
Count
-
1
-
m_pageSize
;
if
(
DataSource
==
null
)
return
;
startIndex
=
DataSource
.
Count
-
m_pageSize
;
if
(
startIndex
<
0
)
startIndex
=
0
;
var
s
=
GetCurrentSource
();
if
(
ShowChanged
!=
null
)
if
(
Show
Source
Changed
!=
null
)
{
ShowChanged
(
s
);
Show
Source
Changed
(
s
);
}
}
public
void
Reload
()
/// <summary>
/// 刷新数据
/// </summary>
public
virtual
void
Reload
()
{
var
s
=
GetCurrentSource
();
if
(
ShowChanged
!=
null
)
if
(
Show
Source
Changed
!=
null
)
{
ShowChanged
(
s
);
Show
Source
Changed
(
s
);
}
}
public
List
<
object
>
GetCurrentSource
()
/// <summary>
/// 获取当前页数据
/// </summary>
/// <returns></returns>
public
virtual
List
<
object
>
GetCurrentSource
()
{
if
(
DataSource
==
null
)
return
null
;
int
intShowCount
=
m_pageSize
;
if
(
intShowCount
+
startIndex
>
DataSource
.
Count
)
intShowCount
=
DataSource
.
Count
-
startIndex
;
...
...
@@ -185,9 +226,11 @@ namespace HZH_Controls.Controls
/// <summary>
/// 控制按钮显示
/// </summary>
/// <param name="blnLeftBtn"></param>
/// <param name="blnRightBtn"></param>
/// <param name="blnLeftBtn">
是否显示上一页,第一页
</param>
/// <param name="blnRightBtn">
是否显示下一页,最后一页
</param>
protected
virtual
void
ShowBtn
(
bool
blnLeftBtn
,
bool
blnRightBtn
)
{
}
}
}
HZH_Controls/HZH_Controls/Forms/FrmAnchor.cs
查看文件 @
ba58962
...
...
@@ -23,6 +23,7 @@ namespace HZH_Controls.Forms
/// </summary>
public
partial
class
FrmAnchor
:
Form
,
IMessageFilter
{
Control
m_parentControl
=
null
;
private
bool
blnDown
=
true
;
#
region
构造函数
/// <summary>
...
...
@@ -36,6 +37,7 @@ namespace HZH_Controls.Forms
/// <param name="deviation">偏移</param>
public
FrmAnchor
(
Control
parentControl
,
Control
childControl
,
Point
?
deviation
=
null
)
{
m_parentControl
=
parentControl
;
InitializeComponent
();
this
.
Size
=
childControl
.
Size
;
this
.
HandleCreated
+=
FrmDownBoard_HandleCreated
;
...
...
@@ -75,6 +77,7 @@ namespace HZH_Controls.Forms
public
FrmAnchor
(
Control
parentControl
,
Size
size
,
Point
?
deviation
=
null
)
{
m_parentControl
=
parentControl
;
InitializeComponent
();
this
.
Size
=
size
;
this
.
HandleCreated
+=
FrmDownBoard_HandleCreated
;
...
...
HZH_Controls/HZH_Controls/Forms/FrmTips.cs
查看文件 @
ba58962
...
...
@@ -363,9 +363,9 @@ namespace HZH_Controls.Forms
public
enum
TipsState
{
Default
=
-
1
,
Success
=
-
11426991
,
Info
=
-
1
3658444
,
Warning
=
-
486394
,
Error
=
-
4377041
Success
=
-
6566849
,
Info
=
-
1
2477983
,
Warning
=
-
357816
,
Error
=
-
1097849
}
}
HZH_Controls/HZH_Controls/HZH_Controls.csproj
查看文件 @
ba58962
...
...
@@ -412,6 +412,7 @@
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="ClassDiagram1.cd" />
<None Include="Resources\alarm.png" />
</ItemGroup>
<ItemGroup>
...
...
HZH_Controls/Test/Form1.Designer.cs
查看文件 @
ba58962
此文件的差异被折叠,
点击展开。
HZH_Controls/Test/Form1.cs
查看文件 @
ba58962
...
...
@@ -57,13 +57,13 @@ namespace Test
}
this
.
ucListExt1
.
SetList
(
lst
);
List
<
KeyValuePair
<
string
,
string
>>
lstHL
=
new
List
<
KeyValuePair
<
string
,
string
>>();
for
(
int
i
=
0
;
i
<
30
;
i
++)
{
List
<
KeyValuePair
<
string
,
string
>>
lstHL
=
new
List
<
KeyValuePair
<
string
,
string
>>();
for
(
int
i
=
0
;
i
<
30
;
i
++)
{
lstHL
.
Add
(
new
KeyValuePair
<
string
,
string
>(
i
.
ToString
(),
"选项"
+
i
));
}
}
this
.
ucHorizontalList1
.
DataSource
=
lstHL
;
this
.
ucHorizontalList1
.
DataSource
=
lstHL
;
}
private
void
timer1_Tick
(
object
sender
,
EventArgs
e
)
...
...
@@ -135,5 +135,10 @@ this.ucHorizontalList1.DataSource = lstHL;
frm
.
ShowDialog
(
this
);
}
private
void
button9_Click
(
object
sender
,
EventArgs
e
)
{
}
}
}
HZH_Controls/Test/FrmTemp1Test.cs
查看文件 @
ba58962
...
...
@@ -19,7 +19,6 @@ namespace Test
private
void
FrmTemp1Test_Load
(
object
sender
,
EventArgs
e
)
{
List
<
DataGridViewColumnEntity
>
lstCulumns
=
new
List
<
DataGridViewColumnEntity
>();
lstCulumns
.
Add
(
new
DataGridViewColumnEntity
()
{
DataField
=
"ID"
,
HeadText
=
"编号"
,
Width
=
70
,
WidthType
=
SizeType
.
Absolute
});
lstCulumns
.
Add
(
new
DataGridViewColumnEntity
()
{
DataField
=
"Name"
,
HeadText
=
"姓名"
,
Width
=
50
,
WidthType
=
SizeType
.
Percent
});
...
...
@@ -27,7 +26,7 @@ namespace Test
this
.
ucDataGridView1
.
Columns
=
lstCulumns
;
this
.
ucDataGridView1
.
IsShowCheckBox
=
true
;
List
<
object
>
lstSource
=
new
List
<
object
>();
for
(
int
i
=
0
;
i
<
1
0
;
i
++)
for
(
int
i
=
0
;
i
<
2
0
;
i
++)
{
TestModel
model
=
new
TestModel
()
{
...
...
@@ -38,7 +37,9 @@ namespace Test
lstSource
.
Add
(
model
);
}
this
.
ucDataGridView1
.
DataSource
=
lstSource
.
ToArray
();
UCPagerControl
page
=
new
UCPagerControl
();
page
.
DataSource
=
lstSource
;
this
.
ucDataGridView1
.
Page
=
page
;
this
.
ucDataGridView1
.
First
();
}
}
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论