gpt4 book ai didi

MouseHover 上的 C# 按钮透明背景

转载 作者:太空宇宙 更新时间:2023-11-03 10:55:02 26 4
gpt4 key购买 nike

我有这个用代码创建的按钮,它有背景图像并且是透明的。到目前为止一切顺利,它有效,可怕的灰色背景颜色消失了。除了当我将鼠标悬停在它上面时,烦人的感觉不断出现。

所以我已经尝试了我能想到的方法,那就是添加一个事件监听器,它将在 MouseHover、Enter 和 Leave 上将背景颜色更改为透明。但似乎没有任何效果。

有什么想法吗?

到目前为止,这是我的代码:

    private void CreateFirstScreen() {
mainForm.BackgroundImage = Image.FromFile(@"[img dir]");

Button nextBtn = new Button();
nextBtn.BackColor = Color.Transparent; <== this works!
nextBtn.BackgroundImage = Image.FromFile(@"[img dir]");
nextBtn.FlatStyle = FlatStyle.Flat;

nextBtn.FlatAppearance.BorderSize = 0;
nextBtn.SetBounds(1555, 820, 274, 106);

mainForm.Controls.Add(nextBtn);


nextBtn.MouseHover += (sender, args) => {
nextBtn.BackColor = Color.Transparent; <= doesn't work
};
nextBtn.MouseEnter += (sender, args) => {
nextBtn.BackColor = Color.Transparent; <= doesn't work
};
nextBtn.MouseLeave += (sender, args) => {
nextBtn.BackColor = Color.Transparent; <= doesn't work
};
nextBtn.Click += (sender, args) => {
CreateSecondScreen(); <= does work
mainForm.Controls.Remove(nextBtn); <= does work
};
}

最佳答案

尝试添加这个:

nextBtn.FlatAppearance.MouseOverBackColor=Color.Transparent;

关于MouseHover 上的 C# 按钮透明背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19844306/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com