【问题标题】:Telerik Winform ButtonTextBox Element Button ParentTelerik Winform ButtonTextBox Element Button Parent
【发布时间】:2021-11-16 04:58:12
【问题描述】:

我正在 C# 中使用 Telerik Winform 尝试一个项目,并希望从 ButtonTextBox 获得 RightButtonItem (RadButtonElement) 的父控件,这是 ButtonTextBox 本身。 尝试使用control.Parent 属性,但返回的对象不是ButtonTextBox 控件。

【问题讨论】:

标签: c# winforms telerik parent


【解决方案1】:

RightButtonItems 集合包含不同的 RadButtonElements。如果您想从内部 RadButtonElements 之一检测父控件,最简单的方法是使用 RadButtonElement.ElementTree.Control 并将其转换为 RadButtonTextBox。

            Dictionary<int, string> glyphs = new Dictionary<int, string>();
        List<RadButtonElement> buttons = new List<RadButtonElement>();
        glyphs.Add(0, "");
        glyphs.Add(1, "");
        glyphs.Add(2, "");
        for (int i = 0; i <= 9 - 1; i++)
        {
            RadButtonElement radButtonElement = new RadButtonElement();
            radButtonElement.DisplayStyle = Telerik.WinControls.DisplayStyle.Text;
            radButtonElement.TextElement.CustomFont = "TelerikWebUI";
            radButtonElement.TextElement.CustomFontSize = 10;
            radButtonElement.TextElement.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
            radButtonElement.Text = glyphs[i];
            buttons.Add(radButtonElement);
        }
        radButtonTextBox1.RightButtonItems.AddRange(buttons[0]);
        radButtonTextBox1.LeftButtonItems.AddRange(buttons[1], buttons[2]);
        radButtonTextBox1.AutoSize = false;
        radButtonTextBox1.Text = "";

        RadButtonTextBox btnTextBox = buttons[1].ElementTree.Control as RadButtonTextBox;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-08-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多