Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
刘韬
/
HZH_Controls
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 5452207c
由
HZH
编写于
2019-08-22 11:20:11 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
listview bug
1 个父辈
2721a706
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
50 行增加
和
28 行删除
HZH_Controls/HZH_Controls/Controls/List/UCListView.Designer.cs
HZH_Controls/HZH_Controls/Controls/List/UCListView.cs
HZH_Controls/Test/FrmTestListView.cs
HZH_Controls/HZH_Controls/Controls/List/UCListView.Designer.cs
查看文件 @
5452207
...
@@ -62,6 +62,7 @@
...
@@ -62,6 +62,7 @@
this
.
Margin
=
new
System
.
Windows
.
Forms
.
Padding
(
0
);
this
.
Margin
=
new
System
.
Windows
.
Forms
.
Padding
(
0
);
this
.
Name
=
"UCListView"
;
this
.
Name
=
"UCListView"
;
this
.
Size
=
new
System
.
Drawing
.
Size
(
462
,
363
);
this
.
Size
=
new
System
.
Drawing
.
Size
(
462
,
363
);
this
.
Load
+=
new
System
.
EventHandler
(
this
.
UCListView_Load
);
this
.
ResumeLayout
(
false
);
this
.
ResumeLayout
(
false
);
}
}
...
...
HZH_Controls/HZH_Controls/Controls/List/UCListView.cs
查看文件 @
5452207
...
@@ -80,7 +80,7 @@ namespace HZH_Controls.Controls
...
@@ -80,7 +80,7 @@ namespace HZH_Controls.Controls
{
{
throw
new
Exception
(
"数据源不是有效的数据类型,列表"
);
throw
new
Exception
(
"数据源不是有效的数据类型,列表"
);
}
}
m_dataSource
=
value
;
m_dataSource
=
value
;
ReloadSource
();
ReloadSource
();
}
}
}
}
...
@@ -149,6 +149,10 @@ namespace HZH_Controls.Controls
...
@@ -149,6 +149,10 @@ namespace HZH_Controls.Controls
public
void
ReloadSource
()
public
void
ReloadSource
()
{
{
ControlHelper
.
FreezeControl
(
this
,
true
);
ControlHelper
.
FreezeControl
(
this
,
true
);
if
(
this
.
panMain
.
Controls
.
Count
<=
0
)
{
ReloadGridStyle
();
}
if
(
m_dataSource
==
null
||
((
IList
)
m_dataSource
).
Count
<=
0
)
if
(
m_dataSource
==
null
||
((
IList
)
m_dataSource
).
Count
<=
0
)
{
{
for
(
int
i
=
this
.
panMain
.
Controls
.
Count
-
1
;
i
>=
0
;
i
--)
for
(
int
i
=
this
.
panMain
.
Controls
.
Count
-
1
;
i
>=
0
;
i
--)
...
@@ -192,7 +196,6 @@ namespace HZH_Controls.Controls
...
@@ -192,7 +196,6 @@ namespace HZH_Controls.Controls
/// </summary>
/// </summary>
public
void
ReloadGridStyle
()
public
void
ReloadGridStyle
()
{
{
Form
frmMain
=
this
.
FindForm
();
Form
frmMain
=
this
.
FindForm
();
if
(
frmMain
!=
null
&&
!
frmMain
.
IsDisposed
&&
frmMain
.
Visible
&&
this
.
Visible
)
if
(
frmMain
!=
null
&&
!
frmMain
.
IsDisposed
&&
frmMain
.
Visible
&&
this
.
Visible
)
{
{
...
@@ -241,41 +244,41 @@ namespace HZH_Controls.Controls
...
@@ -241,41 +244,41 @@ namespace HZH_Controls.Controls
void
UCListView_SelectedItemEvent
(
object
sender
,
EventArgs
e
)
void
UCListView_SelectedItemEvent
(
object
sender
,
EventArgs
e
)
{
{
var
selectedItem
=
sender
as
IListViewItem
;
var
selectedItem
=
sender
as
IListViewItem
;
if
(
m_selectedSource
.
Contains
(
selectedItem
.
DataSource
))
if
(
m_selectedSource
.
Contains
(
selectedItem
.
DataSource
))
{
m_selectedSource
.
Remove
(
selectedItem
.
DataSource
);
selectedItem
.
SetSelected
(
false
);
}
else
{
if
(
m_isMultiple
)
{
{
m_selectedSource
.
Remove
(
selectedItem
.
DataSource
);
m_selectedSource
.
Add
(
selectedItem
.
DataSource
);
selectedItem
.
SetSelected
(
fals
e
);
selectedItem
.
SetSelected
(
tru
e
);
}
}
else
else
{
{
if
(
m_
isMultiple
)
if
(
m_
selectedSource
.
Count
>
0
)
{
{
m_selectedSource
.
Add
(
selectedItem
.
DataSource
);
int
intCount
=
Math
.
Min
(((
IList
)
m_dataSource
).
Count
,
this
.
panMain
.
Controls
.
Count
);
selectedItem
.
SetSelected
(
true
);
for
(
int
i
=
0
;
i
<
intCount
;
i
++)
}
else
{
if
(
m_selectedSource
.
Count
>
0
)
{
{
int
intCount
=
Math
.
Min
(((
IList
)
m_dataSource
).
Count
,
this
.
panMain
.
Controls
.
Count
);
var
item
=
((
IListViewItem
)
this
.
panMain
.
Controls
[
i
]
);
for
(
int
i
=
0
;
i
<
intCount
;
i
++
)
if
(
m_selectedSource
.
Contains
(
item
.
DataSource
)
)
{
{
var
item
=
((
IListViewItem
)
this
.
panMain
.
Controls
[
i
]);
item
.
SetSelected
(
false
);
if
(
m_selectedSource
.
Contains
(
item
.
DataSource
))
break
;
{
item
.
SetSelected
(
false
);
break
;
}
}
}
}
}
}
m_selectedSource
=
new
List
<
object
>()
{
selectedItem
.
DataSource
};
m_selectedSource
=
new
List
<
object
>()
{
selectedItem
.
DataSource
};
selectedItem
.
SetSelected
(
true
);
selectedItem
.
SetSelected
(
true
);
}
}
}
}
if
(
SelectedItemEvent
!=
null
)
if
(
SelectedItemEvent
!=
null
)
{
{
SelectedItemEvent
(
sender
,
e
);
SelectedItemEvent
(
sender
,
e
);
...
@@ -296,12 +299,25 @@ namespace HZH_Controls.Controls
...
@@ -296,12 +299,25 @@ namespace HZH_Controls.Controls
return
;
return
;
Control
item
=
(
Control
)
Activator
.
CreateInstance
(
m_itemType
);
Control
item
=
(
Control
)
Activator
.
CreateInstance
(
m_itemType
);
int
intXCount
=
(
this
.
panMain
.
Width
-
10
)
/
(
item
.
Width
+
10
);
int
intXCount
=
(
this
.
panMain
.
Width
-
10
)
/
(
item
.
Width
+
10
);
m_intCellWidth
=
item
.
Width
+
((
this
.
panMain
.
Width
-
10
)
%
(
item
.
Width
+
10
))
/
intXCount
;
m_intCellWidth
=
item
.
Width
+
((
this
.
panMain
.
Width
-
10
)
%
(
item
.
Width
+
10
))
/
intXCount
;
int
intYCount
=
(
this
.
panMain
.
Height
-
10
)
/
(
item
.
Height
+
10
);
int
intYCount
=
(
this
.
panMain
.
Height
-
10
)
/
(
item
.
Height
+
10
);
m_intCellHeight
=
item
.
Height
+
((
this
.
panMain
.
Height
-
10
)
%
(
item
.
Height
+
10
))
/
intYCount
;
m_intCellHeight
=
item
.
Height
+
((
this
.
panMain
.
Height
-
10
)
%
(
item
.
Height
+
10
))
/
intYCount
;
CellCount
=
intXCount
*
intYCount
;
int
intCount
=
intXCount
*
intYCount
;
if
(
Page
==
null
)
{
if
(((
IList
)
m_dataSource
).
Count
>
intCount
)
{
intXCount
=
(
this
.
panMain
.
Width
-
10
-
20
)
/
(
item
.
Width
+
10
);
m_intCellWidth
=
item
.
Width
+
((
this
.
panMain
.
Width
-
10
-
20
)
%
(
item
.
Width
+
10
))
/
intXCount
;
}
intCount
=
Math
.
Max
(
intCount
,
((
IList
)
m_dataSource
).
Count
);
}
CellCount
=
intCount
;
}
}
#
endregion
#
endregion
...
@@ -309,5 +325,10 @@ namespace HZH_Controls.Controls
...
@@ -309,5 +325,10 @@ namespace HZH_Controls.Controls
{
{
ReloadGridStyle
();
ReloadGridStyle
();
}
}
private
void
UCListView_Load
(
object
sender
,
EventArgs
e
)
{
}
}
}
}
}
HZH_Controls/Test/FrmTestListView.cs
查看文件 @
5452207
...
@@ -21,7 +21,7 @@ namespace Test
...
@@ -21,7 +21,7 @@ namespace Test
private
void
FrmTestListView_Load
(
object
sender
,
EventArgs
e
)
private
void
FrmTestListView_Load
(
object
sender
,
EventArgs
e
)
{
{
List
<
object
>
lstSource
=
new
List
<
object
>();
List
<
object
>
lstSource
=
new
List
<
object
>();
for
(
int
i
=
0
;
i
<
10
00
;
i
++)
for
(
int
i
=
0
;
i
<
2
00
;
i
++)
{
{
lstSource
.
Add
(
"项-"
+
i
);
lstSource
.
Add
(
"项-"
+
i
);
}
}
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论