Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
刘韬
/
HZH_Controls
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 09e1bd73
由
kwwwvagaa
编写于
2020-04-22 21:26:03 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
优化树表格显示
1 个父辈
6b547591
显示空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
141 行增加
和
214 行删除
HZH_Controls/HZH_Controls/Controls/DataGridView/UCDataGridView.cs
HZH_Controls/HZH_Controls/Controls/DataGridView/UCDataGridViewTreeRow.Designer.cs
HZH_Controls/HZH_Controls/Controls/DataGridView/UCDataGridViewTreeRow.cs
HZH_Controls/Test/UC/UCTestGridTable.Designer.cs
HZH_Controls/Test/UC/UCTestTreeGridTable.Designer.cs
HZH_Controls/Test/UC/UCTestTreeGridTable.cs
HZH_Controls/HZH_Controls/Controls/DataGridView/UCDataGridView.cs
查看文件 @
09e1bd7
...
...
@@ -507,6 +507,8 @@ namespace HZH_Controls.Controls
#
endregion
#
region
公共函数
/// <summary>
/// 刷新数据
...
...
@@ -780,6 +782,5 @@ namespace HZH_Controls.Controls
{
}
}
}
HZH_Controls/HZH_Controls/Controls/DataGridView/UCDataGridViewTreeRow.Designer.cs
查看文件 @
09e1bd7
...
...
@@ -50,13 +50,9 @@ namespace HZH_Controls.Controls
{
this
.
panCells
=
new
System
.
Windows
.
Forms
.
TableLayoutPanel
();
this
.
panLeft
=
new
System
.
Windows
.
Forms
.
Panel
();
this
.
panChildGrid
=
new
System
.
Windows
.
Forms
.
Panel
();
this
.
ucDGVChild
=
new
HZH_Controls
.
Controls
.
UCDataGridView
();
this
.
ucSplitLine_V1
=
new
HZH_Controls
.
Controls
.
UCSplitLine_V
();
this
.
panChildLeft
=
new
System
.
Windows
.
Forms
.
Panel
();
this
.
panMain
=
new
System
.
Windows
.
Forms
.
Panel
();
this
.
ucSplitLine_H1
=
new
HZH_Controls
.
Controls
.
UCSplitLine_H
();
this
.
panChildGrid
.
SuspendLayout
();
this
.
ucSplitLine_V1
=
new
HZH_Controls
.
Controls
.
UCSplitLine_V
();
this
.
panMain
.
SuspendLayout
();
this
.
SuspendLayout
();
//
...
...
@@ -71,7 +67,7 @@ namespace HZH_Controls.Controls
this
.
panCells
.
RowCount
=
1
;
this
.
panCells
.
RowStyles
.
Add
(
new
System
.
Windows
.
Forms
.
RowStyle
(
System
.
Windows
.
Forms
.
SizeType
.
Percent
,
100F
));
this
.
panCells
.
RowStyles
.
Add
(
new
System
.
Windows
.
Forms
.
RowStyle
(
System
.
Windows
.
Forms
.
SizeType
.
Absolute
,
55F
));
this
.
panCells
.
Size
=
new
System
.
Drawing
.
Size
(
63
7
,
64
);
this
.
panCells
.
Size
=
new
System
.
Drawing
.
Size
(
63
6
,
64
);
this
.
panCells
.
TabIndex
=
2
;
//
// panLeft
...
...
@@ -85,89 +81,46 @@ namespace HZH_Controls.Controls
this
.
panLeft
.
Tag
=
"0"
;
this
.
panLeft
.
MouseDown
+=
new
System
.
Windows
.
Forms
.
MouseEventHandler
(
this
.
panLeft_MouseDown
);
//
// panChildGrid
//
this
.
panChildGrid
.
Controls
.
Add
(
this
.
ucDGVChild
);
this
.
panChildGrid
.
Controls
.
Add
(
this
.
ucSplitLine_V1
);
this
.
panChildGrid
.
Controls
.
Add
(
this
.
panChildLeft
);
this
.
panChildGrid
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Bottom
;
this
.
panChildGrid
.
Location
=
new
System
.
Drawing
.
Point
(
0
,
65
);
this
.
panChildGrid
.
Name
=
"panChildGrid"
;
this
.
panChildGrid
.
Size
=
new
System
.
Drawing
.
Size
(
661
,
0
);
this
.
panChildGrid
.
TabIndex
=
0
;
this
.
panChildGrid
.
SizeChanged
+=
new
System
.
EventHandler
(
this
.
panChildGrid_SizeChanged
);
//
// ucDGVChild
//
this
.
ucDGVChild
.
Anchor
=
((
System
.
Windows
.
Forms
.
AnchorStyles
)(((
System
.
Windows
.
Forms
.
AnchorStyles
.
Top
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Left
)
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Right
)));
this
.
ucDGVChild
.
BackColor
=
System
.
Drawing
.
Color
.
White
;
this
.
ucDGVChild
.
Columns
=
null
;
this
.
ucDGVChild
.
DataSource
=
null
;
this
.
ucDGVChild
.
HeadFont
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
12F
);
this
.
ucDGVChild
.
HeadHeight
=
40
;
this
.
ucDGVChild
.
HeadPadingLeft
=
0
;
this
.
ucDGVChild
.
HeadTextColor
=
System
.
Drawing
.
Color
.
Black
;
this
.
ucDGVChild
.
IsShowCheckBox
=
false
;
this
.
ucDGVChild
.
IsShowHead
=
false
;
this
.
ucDGVChild
.
Location
=
new
System
.
Drawing
.
Point
(
25
,
0
);
this
.
ucDGVChild
.
Name
=
"ucDGVChild"
;
this
.
ucDGVChild
.
RowHeight
=
40
;
this
.
ucDGVChild
.
RowType
=
typeof
(
HZH_Controls
.
Controls
.
UCDataGridViewRow
);
this
.
ucDGVChild
.
Size
=
new
System
.
Drawing
.
Size
(
636
,
100
);
this
.
ucDGVChild
.
TabIndex
=
0
;
this
.
ucDGVChild
.
SizeChanged
+=
new
System
.
EventHandler
(
this
.
ucDGVChild_SizeChanged
);
//
// ucSplitLine_V1
//
this
.
ucSplitLine_V1
.
BackColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
232
)))),
((
int
)(((
byte
)(
232
)))),
((
int
)(((
byte
)(
232
)))));
this
.
ucSplitLine_V1
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Left
;
this
.
ucSplitLine_V1
.
Location
=
new
System
.
Drawing
.
Point
(
24
,
0
);
this
.
ucSplitLine_V1
.
Name
=
"ucSplitLine_V1"
;
this
.
ucSplitLine_V1
.
Size
=
new
System
.
Drawing
.
Size
(
1
,
0
);
this
.
ucSplitLine_V1
.
TabIndex
=
0
;
this
.
ucSplitLine_V1
.
TabStop
=
false
;
//
// panChildLeft
//
this
.
panChildLeft
.
BackgroundImageLayout
=
System
.
Windows
.
Forms
.
ImageLayout
.
Center
;
this
.
panChildLeft
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Left
;
this
.
panChildLeft
.
Location
=
new
System
.
Drawing
.
Point
(
0
,
0
);
this
.
panChildLeft
.
Name
=
"panChildLeft"
;
this
.
panChildLeft
.
Size
=
new
System
.
Drawing
.
Size
(
24
,
0
);
this
.
panChildLeft
.
TabIndex
=
1
;
this
.
panChildLeft
.
Tag
=
"0"
;
//
// panMain
//
this
.
panMain
.
Controls
.
Add
(
this
.
panCells
);
this
.
panMain
.
Controls
.
Add
(
this
.
panLeft
);
this
.
panMain
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Fill
;
this
.
panMain
.
Location
=
new
System
.
Drawing
.
Point
(
0
,
0
);
this
.
panMain
.
Location
=
new
System
.
Drawing
.
Point
(
1
,
0
);
this
.
panMain
.
Name
=
"panMain"
;
this
.
panMain
.
Size
=
new
System
.
Drawing
.
Size
(
66
1
,
64
);
this
.
panMain
.
Size
=
new
System
.
Drawing
.
Size
(
66
0
,
64
);
this
.
panMain
.
TabIndex
=
0
;
//
// ucSplitLine_H1
//
this
.
ucSplitLine_H1
.
BackColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
232
)))),
((
int
)(((
byte
)(
232
)))),
((
int
)(((
byte
)(
232
)))));
this
.
ucSplitLine_H1
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Bottom
;
this
.
ucSplitLine_H1
.
Location
=
new
System
.
Drawing
.
Point
(
0
,
64
);
this
.
ucSplitLine_H1
.
Location
=
new
System
.
Drawing
.
Point
(
1
,
64
);
this
.
ucSplitLine_H1
.
Name
=
"ucSplitLine_H1"
;
this
.
ucSplitLine_H1
.
Size
=
new
System
.
Drawing
.
Size
(
66
1
,
1
);
this
.
ucSplitLine_H1
.
Size
=
new
System
.
Drawing
.
Size
(
66
0
,
1
);
this
.
ucSplitLine_H1
.
TabIndex
=
1
;
this
.
ucSplitLine_H1
.
TabStop
=
false
;
//
// ucSplitLine_V1
//
this
.
ucSplitLine_V1
.
BackColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
232
)))),
((
int
)(((
byte
)(
232
)))),
((
int
)(((
byte
)(
232
)))));
this
.
ucSplitLine_V1
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Left
;
this
.
ucSplitLine_V1
.
Location
=
new
System
.
Drawing
.
Point
(
0
,
0
);
this
.
ucSplitLine_V1
.
Name
=
"ucSplitLine_V1"
;
this
.
ucSplitLine_V1
.
Size
=
new
System
.
Drawing
.
Size
(
1
,
65
);
this
.
ucSplitLine_V1
.
TabIndex
=
0
;
this
.
ucSplitLine_V1
.
TabStop
=
false
;
this
.
ucSplitLine_V1
.
Visible
=
false
;
//
// UCDataGridViewTreeRow
//
this
.
AutoScaleMode
=
System
.
Windows
.
Forms
.
AutoScaleMode
.
None
;
this
.
BackColor
=
System
.
Drawing
.
Color
.
White
;
this
.
Controls
.
Add
(
this
.
panMain
);
this
.
Controls
.
Add
(
this
.
ucSplitLine_H1
);
this
.
Controls
.
Add
(
this
.
panChildGrid
);
this
.
Controls
.
Add
(
this
.
ucSplitLine_V1
);
this
.
Name
=
"UCDataGridViewTreeRow"
;
this
.
Size
=
new
System
.
Drawing
.
Size
(
661
,
65
);
this
.
panChildGrid
.
ResumeLayout
(
false
);
this
.
panMain
.
ResumeLayout
(
false
);
this
.
ResumeLayout
(
false
);
...
...
@@ -188,24 +141,9 @@ namespace HZH_Controls.Controls
/// </summary>
private
System
.
Windows
.
Forms
.
Panel
panLeft
;
/// <summary>
/// The pan child grid
/// </summary>
private
System
.
Windows
.
Forms
.
Panel
panChildGrid
;
/// <summary>
/// The uc DGV child
/// </summary>
private
UCDataGridView
ucDGVChild
;
/// <summary>
/// The pan child left
/// </summary>
private
System
.
Windows
.
Forms
.
Panel
panChildLeft
;
/// <summary>
/// The pan main
/// </summary>
private
System
.
Windows
.
Forms
.
Panel
panMain
;
/// <summary>
/// The uc split line v1
/// </summary>
private
UCSplitLine_V
ucSplitLine_V1
;
}
}
HZH_Controls/HZH_Controls/Controls/DataGridView/UCDataGridViewTreeRow.cs
查看文件 @
09e1bd7
...
...
@@ -74,6 +74,21 @@ namespace HZH_Controls.Controls
set
;
}
private
int
rowLevel
=
0
;
/// <summary>
/// 折叠的第几层,用于缩进
/// </summary>
public
int
RowLevel
{
get
{
return
rowLevel
;
}
set
{
rowLevel
=
value
;
this
.
Padding
=
new
Padding
(
this
.
panLeft
.
Width
/
2
*
value
,
this
.
Padding
.
Top
,
this
.
panLeft
.
Right
,
this
.
Padding
.
Bottom
);
this
.
ucSplitLine_V1
.
Visible
=
value
>
0
;
}
}
/// <summary>
/// 行号,树状图目前没有给予行号
/// </summary>
...
...
@@ -134,53 +149,55 @@ namespace HZH_Controls.Controls
this
.
Height
=
value
;
}
}
#
endregion
private
List
<
UCDataGridViewTreeRow
>
childrenRows
=
new
List
<
UCDataGridViewTreeRow
>();
public
List
<
UCDataGridViewTreeRow
>
ChildrenRows
{
get
{
return
childrenRows
;
}
set
{
childrenRows
=
value
;
}
}
private
bool
?
isOpened
=
false
;
/// <summary>
///
Initializes a new instance of the <see cref="UCDataGridViewTreeRow" /> class.
///
是否打开状态
/// </summary>
public
UCDataGridViewTreeRow
()
public
bool
?
IsOpened
{
InitializeComponent
();
this
.
ucDGVChild
.
RowType
=
this
.
GetType
();
this
.
SizeChanged
+=
UCDataGridViewTreeRow_SizeChanged
;
this
.
ucDGVChild
.
ItemClick
+=
(
a
,
b
)
=>
get
{
return
isOpened
;
}
set
{
if
(
CellClick
!=
null
)
isOpened
=
value
;
if
(
value
.
HasValue
)
{
CellClick
(
a
,
new
DataGridViewEventArgs
()
panLeft
.
Enabled
=
true
;
if
(
value
.
Value
)
{
CellControl
=
(
a
as
Control
),
CellIndex
=
(
a
as
Control
).
Tag
.
ToInt
()
});
}
};
this
.
ucDGVChild
.
AutoScroll
=
false
;
panLeft
.
BackgroundImage
=
Properties
.
Resources
.
caret_down
;
}
/// <summary>
/// Handles the SizeChanged event of the UCDataGridViewTreeRow control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
void
UCDataGridViewTreeRow_SizeChanged
(
object
sender
,
EventArgs
e
)
{
if
(
this
.
Parent
!=
null
)
else
{
if
(
this
.
Parent
.
Parent
.
Parent
!=
null
&&
this
.
Parent
.
Parent
.
Parent
.
Name
==
"panChildGrid"
&&
this
.
panLeft
.
Tag
.
ToInt
()
==
1
)
panLeft
.
BackgroundImage
=
Properties
.
Resources
.
caret_right
;
}
}
else
{
int
intHeight
=
this
.
Parent
.
Parent
.
Controls
[
0
].
Controls
.
ToArray
().
Sum
(
p
=>
p
.
Height
);
if
(
this
.
Parent
.
Parent
.
Parent
.
Height
!=
intHeight
)
this
.
Parent
.
Parent
.
Parent
.
Height
=
intHeight
;
panLeft
.
BackgroundImage
=
null
;
panLeft
.
Enabled
=
false
;
}
}
}
#
endregion
/// <summary>
/// Initializes a new instance of the <see cref="UCDataGridViewTreeRow" /> class.
/// </summary>
public
UCDataGridViewTreeRow
()
{
InitializeComponent
();
}
/// <summary>
/// 绑定数据到Cell
/// </summary>
/// <returns>返回true则表示已处理过,否则将进行默认绑定(通常只针对有Text值的控件)</returns>
public
void
BindingCellData
()
{
for
(
int
i
=
0
;
i
<
Columns
.
Count
;
i
++)
...
...
@@ -212,47 +229,22 @@ namespace HZH_Controls.Controls
cell
.
SetBindSource
(
DataSource
);
}
}
panLeft
.
Tag
=
0
;
IsOpened
=
false
;
var
proChildrens
=
DataSource
.
GetType
().
GetProperty
(
"Childrens"
);
if
(
proChildrens
!=
null
)
{
var
value
=
proChildrens
.
GetValue
(
DataSource
,
null
);
if
(
value
!=
null
)
{
int
intSourceCount
=
0
;
if
(
value
is
DataTable
)
{
intSourceCount
=
(
value
as
DataTable
).
Rows
.
Count
;
}
else
if
(
typeof
(
IList
).
IsAssignableFrom
(
value
.
GetType
()))
{
intSourceCount
=
(
value
as
IList
).
Count
;
}
if
(
intSourceCount
>
0
)
{
panLeft
.
BackgroundImage
=
Properties
.
Resources
.
caret_right
;
panLeft
.
Enabled
=
true
;
panChildGrid
.
Tag
=
value
;
}
else
{
panLeft
.
BackgroundImage
=
null
;
panLeft
.
Enabled
=
false
;
panChildGrid
.
Tag
=
null
;
}
}
else
{
panLeft
.
BackgroundImage
=
null
;
panLeft
.
Enabled
=
false
;
panChildGrid
.
Tag
=
null
;
IsOpened
=
null
;
}
}
else
{
panLeft
.
BackgroundImage
=
null
;
panLeft
.
Enabled
=
false
;
panChildGrid
.
Tag
=
null
;
IsOpened
=
null
;
}
}
...
...
@@ -308,6 +300,7 @@ namespace HZH_Controls.Controls
intColumnsCount
++;
}
this
.
panCells
.
ColumnCount
=
intColumnsCount
;
bool
blnFirst
=
true
;
for
(
int
i
=
0
;
i
<
intColumnsCount
;
i
++)
{
Control
c
=
null
;
...
...
@@ -320,29 +313,16 @@ namespace HZH_Controls.Controls
box
.
TextValue
=
""
;
box
.
Size
=
new
Size
(
30
,
30
);
box
.
Dock
=
DockStyle
.
Fill
;
box
.
CheckedChangeEvent
+=
(
a
,
b
)
=>
{
IsChecked
=
box
.
Checked
;
if
(
this
.
ucDGVChild
.
Rows
!=
null
)
{
this
.
ucDGVChild
.
Rows
.
ForEach
(
p
=>
p
.
IsChecked
=
box
.
Checked
);
if
(
CheckBoxChangeEvent
!=
null
)
{
CheckBoxChangeEvent
(
a
,
new
DataGridViewEventArgs
()
{
CellControl
=
box
,
CellIndex
=
0
});
}
}
};
c
=
box
;
}
else
{
var
item
=
Columns
[
i
-
(
IsShowCheckBox
?
1
:
0
)];
this
.
panCells
.
ColumnStyles
.
Add
(
new
System
.
Windows
.
Forms
.
ColumnStyle
(
item
.
WidthType
,
item
.
Width
));
var
w
=
item
.
Width
-
(
blnFirst
?
(
this
.
panLeft
.
Width
/
2
*
rowLevel
)
:
0
);
if
(
w
<
5
)
w
=
5
;
this
.
panCells
.
ColumnStyles
.
Add
(
new
System
.
Windows
.
Forms
.
ColumnStyle
(
item
.
WidthType
,
w
));
blnFirst
=
false
;
if
(
item
.
CustomCellType
==
null
)
{
Label
lbl
=
new
Label
();
...
...
@@ -377,21 +357,7 @@ namespace HZH_Controls.Controls
}
}
/// <summary>
/// Handles the SizeChanged event of the panChildGrid control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
private
void
panChildGrid_SizeChanged
(
object
sender
,
EventArgs
e
)
{
int
intHeight
=
RowHeight
+
panChildGrid
.
Height
;
if
(
panChildGrid
.
Height
!=
0
)
this
.
ucDGVChild
.
Height
=
panChildGrid
.
Height
;
if
(
this
.
Height
!=
intHeight
)
{
this
.
Height
=
intHeight
;
}
}
/// <summary>
/// Handles the MouseDown event of the panLeft control.
...
...
@@ -402,14 +368,27 @@ namespace HZH_Controls.Controls
{
try
{
if
(!
IsOpened
.
HasValue
)
return
;
ControlHelper
.
FreezeControl
(
this
.
FindForm
(),
true
);
if
(
panLeft
.
Tag
.
ToInt
()
==
0
)
if
(
!
IsOpened
.
Value
)
{
var
value
=
panChildGrid
.
Tag
;
if
(
value
!=
null
)
IsOpened
=
!
IsOpened
;
if
(
childrenRows
.
Count
>
0
)
{
panLeft
.
BackgroundImage
=
Properties
.
Resources
.
caret_down
;
panLeft
.
Tag
=
1
;
childrenRows
.
ForEach
(
p
=>
{
p
.
IsChecked
=
IsChecked
;
p
.
Visible
=
true
;
});
}
else
{
var
proChildrens
=
DataSource
.
GetType
().
GetProperty
(
"Childrens"
);
if
(
proChildrens
!=
null
)
{
var
value
=
proChildrens
.
GetValue
(
DataSource
,
null
);
int
intSourceCount
=
0
;
if
(
value
is
DataTable
)
{
...
...
@@ -419,40 +398,44 @@ namespace HZH_Controls.Controls
{
intSourceCount
=
(
value
as
IList
).
Count
;
}
this
.
panChildGrid
.
Height
=
RowHeight
*
intSourceCount
;
if
(
panChildGrid
.
Height
>
0
)
for
(
int
i
=
intSourceCount
-
1
;
i
>=
0
;
i
--)
{
if
(
value
!=
this
.
ucDGVChild
.
DataSource
)
UCDataGridViewTreeRow
row
=
new
UCDataGridViewTreeRow
();
if
(
value
is
DataTable
)
{
this
.
ucDGVChild
.
Columns
=
Columns
;
this
.
ucDGVChild
.
RowHeight
=
RowHeight
;
this
.
ucDGVChild
.
HeadPadingLeft
=
this
.
panLeft
.
Width
;
this
.
ucDGVChild
.
IsShowCheckBox
=
IsShowCheckBox
;
this
.
ucDGVChild
.
DataSource
=
value
;
this
.
ucDGVChild
.
Rows
.
ForEach
(
p
=>
p
.
IsChecked
=
this
.
IsChecked
);
}
}
}
row
.
DataSource
=
(
value
as
DataTable
).
Rows
[
i
];
}
else
{
Control
[]
cs
=
panChildGrid
.
Controls
.
Find
(
"panLeft"
,
true
);
foreach
(
var
item
in
cs
)
{
item
.
Tag
=
0
;
item
.
BackgroundImage
=
Properties
.
Resources
.
caret_right
;
row
.
DataSource
=
(
value
as
IList
)[
i
];
}
row
.
RowLevel
=
RowLevel
+
1
;
row
.
Columns
=
Columns
;
row
.
IsShowCheckBox
=
IsShowCheckBox
;
row
.
ReloadCells
();
row
.
BindingCellData
();
Control
rowControl
=
(
row
as
Control
);
row
.
RowHeight
=
m_rowHeight
;
rowControl
.
Dock
=
DockStyle
.
Top
;
row
.
CellClick
+=
(
a
,
b
)
=>
{
CellClick
(
rowControl
,
b
);
};
row
.
CheckBoxChangeEvent
+=
(
a
,
b
)
=>
{
CheckBoxChangeEvent
(
rowControl
,
b
);
};
row
.
RowCustomEvent
+=
(
a
,
b
)
=>
{
if
(
RowCustomEvent
!=
null
)
{
RowCustomEvent
(
a
,
b
);
}
};
row
.
SourceChanged
+=
SourceChanged
;
ChildrenRows
.
Add
(
row
);
row
.
RowIndex
=
ChildrenRows
.
IndexOf
(
row
);
this
.
Parent
.
Controls
.
Add
(
rowControl
);
var
index
=
this
.
Parent
.
Controls
.
GetChildIndex
(
this
);
this
.
Parent
.
Controls
.
SetChildIndex
(
row
,
index
);
Control
[]
cs1
=
panChildGrid
.
Controls
.
Find
(
"panChildGrid"
,
true
);
foreach
(
var
item
in
cs1
)
{
item
.
Height
=
0
;
}
panChildGrid
.
Height
=
0
;
panLeft
.
BackgroundImage
=
Properties
.
Resources
.
caret_right
;
}
}
}
else
{
HideChildrenRows
(
this
);
this
.
Height
=
m_rowHeight
;
panLeft
.
Tag
=
0
;
}
}
finally
...
...
@@ -461,14 +444,17 @@ namespace HZH_Controls.Controls
}
}
/// <summary>
/// Handles the SizeChanged event of the ucDGVChild control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
private
void
ucDGVChild_SizeChanged
(
object
sender
,
EventArgs
e
)
private
void
HideChildrenRows
(
UCDataGridViewTreeRow
row
)
{
if
(
row
.
ChildrenRows
.
Count
>
0
)
{
foreach
(
var
item
in
row
.
ChildrenRows
)
{
HideChildrenRows
(
item
);
item
.
Hide
();
}
row
.
IsOpened
=
false
;
}
}
}
}
HZH_Controls/Test/UC/UCTestGridTable.Designer.cs
查看文件 @
09e1bd7
...
...
@@ -37,6 +37,7 @@
this
.
ucDataGridView1
.
BackColor
=
System
.
Drawing
.
Color
.
White
;
this
.
ucDataGridView1
.
Columns
=
null
;
this
.
ucDataGridView1
.
DataSource
=
null
;
this
.
ucDataGridView1
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Fill
;
this
.
ucDataGridView1
.
HeadFont
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
12F
);
this
.
ucDataGridView1
.
HeadHeight
=
40
;
this
.
ucDataGridView1
.
HeadPadingLeft
=
0
;
...
...
@@ -47,13 +48,13 @@
this
.
ucDataGridView1
.
Name
=
"ucDataGridView1"
;
this
.
ucDataGridView1
.
RowHeight
=
41
;
this
.
ucDataGridView1
.
RowType
=
typeof
(
HZH_Controls
.
Controls
.
UCDataGridViewRow
);
this
.
ucDataGridView1
.
Size
=
new
System
.
Drawing
.
Size
(
7
22
,
583
);
this
.
ucDataGridView1
.
Size
=
new
System
.
Drawing
.
Size
(
7
39
,
599
);
this
.
ucDataGridView1
.
TabIndex
=
4
;
//
// UCTestGridTable
//
this
.
AutoScaleMode
=
System
.
Windows
.
Forms
.
AutoScaleMode
.
None
;
this
.
BackColor
=
System
.
Drawing
.
Color
.
Black
;
this
.
BackColor
=
System
.
Drawing
.
Color
.
Transparent
;
this
.
Controls
.
Add
(
this
.
ucDataGridView1
);
this
.
Name
=
"UCTestGridTable"
;
this
.
Size
=
new
System
.
Drawing
.
Size
(
739
,
599
);
...
...
HZH_Controls/Test/UC/UCTestTreeGridTable.Designer.cs
查看文件 @
09e1bd7
...
...
@@ -37,6 +37,7 @@
this
.
ucDataGridView1
.
BackColor
=
System
.
Drawing
.
Color
.
White
;
this
.
ucDataGridView1
.
Columns
=
null
;
this
.
ucDataGridView1
.
DataSource
=
null
;
this
.
ucDataGridView1
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Fill
;
this
.
ucDataGridView1
.
HeadFont
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
12F
);
this
.
ucDataGridView1
.
HeadHeight
=
40
;
this
.
ucDataGridView1
.
HeadPadingLeft
=
24
;
...
...
@@ -47,16 +48,16 @@
this
.
ucDataGridView1
.
Name
=
"ucDataGridView1"
;
this
.
ucDataGridView1
.
RowHeight
=
41
;
this
.
ucDataGridView1
.
RowType
=
typeof
(
HZH_Controls
.
Controls
.
UCDataGridViewRow
);
this
.
ucDataGridView1
.
Size
=
new
System
.
Drawing
.
Size
(
8
07
,
655
);
this
.
ucDataGridView1
.
Size
=
new
System
.
Drawing
.
Size
(
8
17
,
674
);
this
.
ucDataGridView1
.
TabIndex
=
5
;
//
// UCTestTreeGridTable
//
this
.
AutoScaleMode
=
System
.
Windows
.
Forms
.
AutoScaleMode
.
None
;
this
.
BackColor
=
System
.
Drawing
.
Color
.
Black
;
this
.
BackColor
=
System
.
Drawing
.
Color
.
Transparent
;
this
.
Controls
.
Add
(
this
.
ucDataGridView1
);
this
.
Name
=
"UCTestTreeGridTable"
;
this
.
Size
=
new
System
.
Drawing
.
Size
(
8
25
,
674
);
this
.
Size
=
new
System
.
Drawing
.
Size
(
8
17
,
674
);
this
.
Load
+=
new
System
.
EventHandler
(
this
.
UCTestTreeGridTable_Load
);
this
.
ResumeLayout
(
false
);
...
...
HZH_Controls/Test/UC/UCTestTreeGridTable.cs
查看文件 @
09e1bd7
...
...
@@ -23,7 +23,7 @@ namespace Test.UC
{
this
.
ucDataGridView1
.
RowType
=
typeof
(
UCDataGridViewTreeRow
);
List
<
DataGridViewColumnEntity
>
lstCulumns
=
new
List
<
DataGridViewColumnEntity
>();
lstCulumns
.
Add
(
new
DataGridViewColumnEntity
()
{
DataField
=
"ID"
,
HeadText
=
"编号"
,
Width
=
7
0
,
WidthType
=
SizeType
.
Absolute
});
lstCulumns
.
Add
(
new
DataGridViewColumnEntity
()
{
DataField
=
"ID"
,
HeadText
=
"编号"
,
Width
=
10
0
,
WidthType
=
SizeType
.
Absolute
});
lstCulumns
.
Add
(
new
DataGridViewColumnEntity
()
{
DataField
=
"Name"
,
HeadText
=
"姓名"
,
Width
=
150
,
WidthType
=
SizeType
.
Absolute
});
lstCulumns
.
Add
(
new
DataGridViewColumnEntity
()
{
DataField
=
"Age"
,
HeadText
=
"年龄"
,
Width
=
150
,
WidthType
=
SizeType
.
Absolute
});
lstCulumns
.
Add
(
new
DataGridViewColumnEntity
()
{
DataField
=
"Birthday"
,
HeadText
=
"生日"
,
Width
=
150
,
WidthType
=
SizeType
.
Absolute
,
Format
=
(
a
)
=>
{
return
((
DateTime
)
a
).
ToString
(
"yyyy-MM-dd"
);
}
});
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论