将日期时间选择器添加到C#中的StatusStrip控件中
本文关键字:中的 StatusStrip 控件 日期 时间 选择器 添加 | 更新日期: 2023-09-27 18:28:29
我想在StatusStrip控件中添加一个日期时间选择器来显示今天的日期,那么有没有其他方法可以将标签和进度条之外的其他控件添加到StatusStripe控件中??
是的,请从检查
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);
}
}