小编Fer*_*eri的帖子

在下拉菜单中显示 ToolStripControlHost 的图像

我有一个 ToolStripSplitButton,下拉列表中包含各种元素。其中之一是包含在 ToolStripControlHost 中的 Trackbar,称为 ToolStripTrackbarItem。它的代码(我从 stackoverflow 得到的):

using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using System.Windows.Forms.Design;

namespace Application
{
    [System.ComponentModel.DesignerCategory("code")]
    [System.Windows.Forms.Design.ToolStripItemDesignerAvailability(ToolStripItemDesignerAvailability.ContextMenuStrip | ToolStripItemDesignerAvailability.MenuStrip)]

    public class ToolStripTrackbarItem : ToolStripControlHost
    {
        public ToolStripTrackbarItem()
            : base(CreateControlInstance())
        {
            this.Size = Control.Size;
        }
        public TrackBar TrackBar
        {
            get { return Control as TrackBar; }
        }
        private static Control CreateControlInstance()
        {
            TrackBar t = new TrackBar();
            t.AutoSize = false;
            return t;
        }
        [DefaultValue(0)]
        public int Value
        {
            get { return TrackBar.Value; }
            set { …
Run Code Online (Sandbox Code Playgroud)

.net c# toolstrip winforms toolstripcontrolhost

3
推荐指数
1
解决办法
1158
查看次数

标签 统计

.net ×1

c# ×1

toolstrip ×1

toolstripcontrolhost ×1

winforms ×1