Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
刘韬
/
HZH_Controls
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 98769f7e
由
刘韬
编写于
2025-05-30 20:16:57 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
Combox添加 选项disable功能, 以*开头的value开头
1 个父辈
eea8cf07
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
41 行增加
和
4 行删除
HZH_Controls/HZH_Controls/Controls/ComboBox/UCCombox.cs
HZH_Controls/HZH_Controls/Controls/DateTime/UCTimePanel.cs
HZH_Controls/HZH_Controls/Controls/ComboBox/UCCombox.cs
查看文件 @
98769f7
...
...
@@ -201,6 +201,7 @@ namespace HZH_Controls.Controls
set
{
_source
=
value
;
_selectedIndex
=
-
1
;
_selectedValue
=
""
;
_selectedItem
=
new
KeyValuePair
<
string
,
string
>();
...
...
@@ -557,11 +558,26 @@ namespace HZH_Controls.Controls
{
if
(
_frmAnchor
!=
null
&&
!
_frmAnchor
.
IsDisposed
&&
_frmAnchor
.
Visible
)
{
SelectedValue
=
sender
.
ToString
();
string
selectedValue
=
sender
.
ToString
();
// Check if the selected item starts with *
var
selectedItem
=
_source
.
FirstOrDefault
(
x
=>
x
.
Key
==
selectedValue
);
if
(
selectedItem
.
Value
!=
null
&&
selectedItem
.
Value
.
StartsWith
(
"*"
))
{
// Don't change selection or trigger event for disabled items
_frmAnchor
.
Close
();
return
;
}
SelectedValue
=
selectedValue
;
_frmAnchor
.
Close
();
}
}
// Add a method to check if an item is disabled
private
bool
IsItemDisabled
(
KeyValuePair
<
string
,
string
>
item
)
{
return
item
.
Value
.
StartsWith
(
"*"
);
}
/// <summary>
/// Handles the Load event of the UCComboBox control.
/// </summary>
...
...
HZH_Controls/HZH_Controls/Controls/DateTime/UCTimePanel.cs
查看文件 @
98769f7
...
...
@@ -205,8 +205,29 @@ namespace HZH_Controls.Controls
{
if
(
lstSource
!=
null
&&
index
<
lstSource
.
Count
)
{
btn
.
BtnText
=
lstSource
[
index
].
Value
;
// 检查是否是禁用项(以*开头)
bool
isDisabled
=
lstSource
[
index
].
Value
.
StartsWith
(
"*"
);
string
displayText
=
isDisabled
?
lstSource
[
index
].
Value
.
Substring
(
1
)
:
lstSource
[
index
].
Value
;
btn
.
BtnText
=
displayText
;
btn
.
Tag
=
lstSource
[
index
].
Key
;
// 设置禁用项的样式
if
(
isDisabled
)
{
btn
.
FillColor
=
Color
.
FromArgb
(
240
,
240
,
240
);
// 灰色背景
btn
.
BtnForeColor
=
Color
.
Gray
;
// 灰色文字
btn
.
Enabled
=
false
;
// 禁用按钮
}
else
{
btn
.
FillColor
=
Color
.
White
;
btn
.
BtnForeColor
=
Color
.
FromArgb
(
66
,
66
,
66
);
btn
.
Enabled
=
true
;
}
index
++;
}
else
...
...
@@ -309,7 +330,7 @@ namespace HZH_Controls.Controls
void
btn_BtnClick
(
object
sender
,
EventArgs
e
)
{
var
btn
=
(
UCBtnExt
)
sender
;
if
(
btn
.
Tag
==
null
)
if
(
btn
.
Tag
==
null
||
!
btn
.
Enabled
)
// 检查按钮是否被禁用
return
;
SelectBtn
=
btn
;
}
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论