文件名称:wpf TextBox 自定义菜单
文件大小:1KB
文件格式:CS
更新时间:2018-06-17 08:56:49
TextBox 自定义菜单
右键菜单 ContextMenu cont = new ContextMenu(); cont.Items.Add(new MenuItem() { Header="删除"}); cont.Items.Add(new MenuItem() { Header = "添加" }); textBox1.ContextMenu = cont; for (int i = 0; i < cont.Items.Count; i++) { MenuItem item = (MenuItem)cont.Items[i]; item.Click += delegate(object sender,RoutedEventArgs e) { MessageBox.Show(item.Header.ToString()); }; }