0

我想在 StatusStrip 控件中添加一个 datetimepicker 以显示今天的日期,那么除了标签和进度条之外,还有什么方法可以将其他控件添加到 StatusStrip 控件中?

4

1 回答 1

0

是的,请从以下位置检查:

https://social.msdn.microsoft.com/forums/windows/en-us/edbd92be-76ee-49b1-b7c6-f6522992a14a/using-toolstripcontrolhost-with-datetimepicker

[ToolStripItemDesignerAvailability(ToolStripItemDesignerAvailability.ToolStrip)]
public class ToolStripDateTimePicker : ToolStripControlHost
{
    private FlowLayoutPanel controlPanel;
    private DateTimePicker picker = new DateTimePicker();

    public ToolStripDateTimePicker()
        : base(new FlowLayoutPanel())
    {
        controlPanel = (FlowLayoutPanel)base.Control;
        controlPanel.BackColor = Color.Transparent;

        AutoSize = false;

        controlPanel.Controls.Add(picker);
    }

    public DateTime Value
    {
        get { return this.picker.Value; }
        set { this.picker.Value = value; }
    }

    protected override void OnSubscribeControlEvents(Control control)
    {
        base.OnSubscribeControlEvents(control);
    }

    protected override void OnUnsubscribeControlEvents(Control control)
    {
        base.OnUnsubscribeControlEvents(control);
    }
}
于 2015-09-02T09:57:13.813 回答