烦请各位高手指点迷津:《C#编程语言设计与开发》上的一道例题,谢谢 添加Reference:System.ServiceProcess.dll 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 在右侧上部项目上点右键,添加->引用,在弹出的对话框中确认选择了.NET页,所以选择System.ServiceProcess。 先谢谢楼上的两位。不过我试了下还是不行反而引出了更多的错误错误 1 “System.Windows.Forms.Control”并不包含“DisplayName”的定义错误 2 “System.Windows.Forms.Control”并不包含“Status”的定义错误 3 当前上下文中不存在名称“ServiceControllerStatus”错误 4 当前上下文中不存在名称“RefreshList”错误 5 当前上下文中不存在名称“controller”错误 6 当前上下文中不存在名称“controller”错误 7 当前上下文中不存在名称“controller”错误 8 当前上下文中不存在名称“controller”错误 9 当前上下文中不存在名称“ServiceControllerStatus”错误 10 当前上下文中不存在名称“RefreshList”错误 11 当前上下文中不存在名称“controller”错误 12 当前上下文中不存在名称“controller”错误 13 当前上下文中不存在名称“controller”错误 14 当前上下文中不存在名称“controller”错误 15 当前上下文中不存在名称“ServiceControllerStatus”错误 16 当前上下文中不存在名称“RefreshList”错误 17 当前上下文中不存在名称“controller”错误 18 当前上下文中不存在名称“controller”错误 19 当前上下文中不存在名称“controller”错误 20 当前上下文中不存在名称“controller”错误 21 当前上下文中不存在名称“ServiceControllerStatus”错误 22 当前上下文中不存在名称“RefreshList”错误 23 当前上下文中不存在名称“controller” private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { control = (System.ServiceProcess.ServiceController) listBox1.SelectedItem; textBox1.Text = Control.DisplayName; switch (Control.Status)注意注意,应该是 control.DisplayName 吧,下边的也是,小心 IntelliSense!如果用 Control.DisplayName,编译器会误以为你想调用 System.Windows.Forms.Control 类的静态方法 DisplayName,而非 System.ServiceProcess.ServiceController 类的某个实例的属性(control.DisplayName)。 问题总算解决了谢谢LaoBai_2006 !!! 也感谢lalac和Eric_zdhz的热心帮助总之谢谢大家^_^ C#如何将这个UFT8码转换为汉字。见例子: c# 状态条StatusStrip 没有ToolStripButton咋整 Literal用jQuery怎么绑定传过来的数据表格 treeview新增节点后触发什么事件? 三级联动 定义一个工具栏后,怎么使得工具栏上的各个按钮调用相关的方法发生作用又不会相互干扰? 远程屏幕监控 继承的问题 如何获得Form中的焦点在不同控件间的变化的事件 各位,搞不懂string的长度问题? DataGridView导出execl,有人会么 难题 !帮忙。谢谢
错误 2 “System.Windows.Forms.Control”并不包含“Status”的定义
错误 3 当前上下文中不存在名称“ServiceControllerStatus”
错误 4 当前上下文中不存在名称“RefreshList”
错误 5 当前上下文中不存在名称“controller”
错误 6 当前上下文中不存在名称“controller”
错误 7 当前上下文中不存在名称“controller”
错误 8 当前上下文中不存在名称“controller”
错误 9 当前上下文中不存在名称“ServiceControllerStatus”
错误 10 当前上下文中不存在名称“RefreshList”
错误 11 当前上下文中不存在名称“controller”
错误 12 当前上下文中不存在名称“controller”
错误 13 当前上下文中不存在名称“controller”
错误 14 当前上下文中不存在名称“controller”
错误 15 当前上下文中不存在名称“ServiceControllerStatus”
错误 16 当前上下文中不存在名称“RefreshList”
错误 17 当前上下文中不存在名称“controller”
错误 18 当前上下文中不存在名称“controller”
错误 19 当前上下文中不存在名称“controller”
错误 20 当前上下文中不存在名称“controller”
错误 21 当前上下文中不存在名称“ServiceControllerStatus”
错误 22 当前上下文中不存在名称“RefreshList”
错误 23 当前上下文中不存在名称“controller”
{
control = (System.ServiceProcess.ServiceController)
listBox1.SelectedItem;
textBox1.Text = Control.DisplayName;
switch (Control.Status)
注意注意,应该是 control.DisplayName 吧,下边的也是,小心 IntelliSense!
如果用 Control.DisplayName,编译器会误以为你想调用 System.Windows.Forms.Control 类的静态方法 DisplayName,而非 System.ServiceProcess.ServiceController 类的某个实例的属性(control.DisplayName)。