GetDlgItem(IDC_EDIT)->SetWindowText(_T("你的字符串"))
你需要把ToolStripMenuItem强制转换为ToolStripDropDownItem类型才能添加子项,其实你自己看看Form1.Designer.cs里设计器自动生成的代码就会明白了,方法如下
private void button1_Click(object sender, EventArgs e)
{
((ToolStripDropDownItem)(((ToolStripDropDownItem)contextMenuStrip1.Items["aToolStripMenuItem"]).DropDownItems["eToolStripMenuItem"])).DropDownItems.Add(new ToolStripMenuItem("h"))
//或者
ToolStripDropDownItem ts = ((ToolStripDropDownItem)contextMenuStrip1.Items["aToolStripMenuItem"])
ts = ((ToolStripDropDownItem)ts.DropDownItems["eToolStripMenuItem"])
ts.DropDownItems.Add(new ToolStripMenuItem("h"))
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)