【问题标题】:Adding user controls to the winforms statusstrip control将用户控件添加到 winforms statusstrip 控件
【发布时间】:2014-08-31 06:09:36
【问题描述】:

有没有办法将我自己的用户控件添加到 winfroms statusstrip 控件?

我想创建一个可绑定标签,以便我可以将排序顺序描述绑定到我的控制器。

状态条似乎允许添加一个 StatusLabel 控件,但这并没有实现 IBindableComponent,如果控件可以绑定到某些东西,则需要它。

【问题讨论】:

    标签: c# winforms data-binding


    【解决方案1】:
    public class BindableToolStripStatusLabel : ToolStripStatusLabel, IBindableComponent
    
    public class BindableStatusBarLabel :  ToolStripLabel, IBindableComponent
    {
        private ControlBindingsCollection _bindings;
    
        private BindingContext _context;
    
        public BindingContext BindingContext
        {
            get
            {
                if (_context == null)
                {
                    _context = new BindingContext();
                }
                return _context;
            }
            set
            {
                _context = value;
            }
        }
    
        public ControlBindingsCollection DataBindings
        {
            get
            {
                if (_bindings == null)
                {
                    _bindings = new ControlBindingsCollection(this);
                }
                return _bindings;
            }
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-08-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-01
      • 1970-01-01
      相关资源
      最近更新 更多