Winform 中动态创建控件问题!急!!
//动态创建日期控件
DateTimePicker dtpStartTime = new DateTimePicker();
dtpStartTime.Name = "dtpStart";
dtpStartTime.Format = DateTimePickerFormat.Custom;
dtpStartTime.Width = 127;
dtpStartTime.CustomFormat = "yyyy-MM-dd HH:mm";
//向工具栏指定位置插入创建的日期控件(ToolStrip控件)
this.mainToolStrip.Items.Insert(1, new ToolStripControlHost(dtpStartTime));
//显示控件的Name
MessageBox.Show(this.mainToolStrip.Items[1].Name);
应该显示的值为:dtpStart,可是结果显示为空值,很是不解。
Text值能显示出来。各位大侠,给点力!是不是这个ToolStrip控件有什么特殊设置?