【问题标题】:C#- Custom Property of Custom ControlsC#- 自定义控件的自定义属性
【发布时间】:2018-10-02 10:44:56
【问题描述】:

我在使用 windows 媒体播放器控件的 windows 窗体应用程序中使用 c# 创建自定义控件。我想创建一个属性isPlaying 作为布尔值。如果为真,则视频应播放,如果为假,则应暂停。

简单来说,我创建了一个新的用户控件,并在其中插入了一个 windows 媒体播放器控件,并且我将其控件框保留在控件之外,因此它不可见。我现在想为其创建一个名为 isPlaying 的真/假属性,如果为真,则视频应播放,如果为假,则应暂停。

【问题讨论】:

  • 来吧,你可以做到的。
  • 但是@SteppingRazor 怎么样?这是我第一次使用 C# .....
  • @styx 。这个问题要求字符串属性.....我要求布尔值......
  • @tejasgupta 然后阅读教程

标签: c# visual-studio winforms custom-controls custom-properties


【解决方案1】:

你的意思是这么简单吗?

private bool _isPlaying = false;

public bool Isplaying
{
    get { return _isPlaying; }
    set 
    {
        _isPlaying = value;

        if (_isPlaying)
        {
            // play vid here
        }
        else
        {
           // stop video here
        }
    }
}

【讨论】:

  • 让我试试@guidoG
猜你喜欢
  • 2014-11-26
  • 1970-01-01
  • 2011-02-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多