gpt4 book ai didi

.net - Telerik,如何在 RadForm TitleBar 中正确添加 RadButtonElement?

转载 作者:行者123 更新时间:2023-12-02 07:51:34 24 4
gpt4 key购买 nike

我正在尝试在标题栏中添加一个按钮,我想给它提供与其他按钮相同的外观,但我无法做到这一点,请参阅:

enter image description here

请注意,我的新按钮的颜色比其他按钮更亮,而且尺寸突出于泛黄的边框之外。

这是我正在使用的代码:

Imports Telerik.WinControls.UI

Public Class RadForm_TestForm : Inherits RadForm

Public Sub New()

' This call is required by the designer.
InitializeComponent()

' Set the RadForm design.
With Me

.ThemeName = "VisualStudio2012Dark" ' The visual theme.
.FormElement.Border.ForeColor = Color.Gold ' Set the borders color.
.FormElement.Border.Width = 1I ' Set the borders width.
.FormElement.TitleBar.BorderPrimitive.ForeColor = Color.Red
.FormElement.TitleBar.ForeColor = Color.LightGray ' Set the TitleBar text color.
.FormElement.TitleBar.MinimizeButton.Enabled = False

End With

' Create a RadButtonElement.
Dim SystrayButton As New RadButtonElement()
With SystrayButton ' Set the RadForm design.

.Text = "."
.ShowBorder = False
.AutoSize = False

.Size = Me.FormElement.TitleBar.MinimizeButton.Size
' .ButtonFillElement.BackColor = Me.FormElement.TitleBar.MinimizeButton.BackColor

End With

' Add the Button in the TitleBar.
Me.FormElement.TitleBar.Children(2).Children(0).Children.Insert(0, SystrayButton)

End Sub

End Class

请注意,在上面的代码中,此行被禁用:

.ButtonFillElement.BackColor = Me.FormElement.TitleBar.MinimizeButton.BackColor

因为如果我以这种方式改变颜色,如果我将鼠标放在按钮上,当它聚焦时它不会改变颜色。

Update:

也许解决方案可以在 RadButtonElement 上应用与我的 RadForm 相同的主题?

我读过这个:http://www.telerik.com/forums/apply-theme-to-radbuttonelement

...但我真的不明白该怎么做,我没有任何“DefaultStyleBuilder”,而且我在 telerik 中找不到关于这意味着什么的信息。

最佳答案

+1 我看到了难题。

如果你想在标题栏中显示按钮的悬停、按下和正常状态,你需要创建三个图像并将它们应用到鼠标事件上,即在 MouseEnter 上应用悬停图像,在 MouseLeave 上应用正常图像,在 MouseLeave 上应用悬停图像。按下鼠标时按下图像。

我看到按钮与黄线稍微重叠,因此您可能需要使用图像来解决此问题。

像您所说的那样设置 RadButton BackColors 将阻止默认的悬停、按下和正常状态行为。

看起来您做得正确 - 一个细微的变化是使用 TitleBar.SystemButtons 而不是遍历继承的 TitleBar.Children(2).Children(0).Children .

以下是您可以执行此操作的方法:

RadButtonElement btn = new RadButtonElement();
btn.ShowBorder = false;
btn.Image = Resources.NormalState;
this.FormElement.TitleBar.SystemButtons.Children.Insert(0,btn);

ps 我认为乱搞“StyleBuilders”不会让您实现您想要的外观,顺便说一句,这个请求已向 Telerik 建议:http://feedback.telerik.com/Project/154/Feedback/Details/109772-add-helpbutton-at-the-titlebar-of-radform

关于.net - Telerik,如何在 RadForm TitleBar 中正确添加 RadButtonElement?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25635610/

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