第6章_窗体、控件和组件.ppt
文本预览下载声明
6.8.2 TreeView控件 【例6-18】演示TreeView控件的用法。 设计界面如下: 6.9其他常用控件 1、选项卡控件(TabControl) TabControl控件用于创建带有多个选项卡(TabPages)的窗口,每个选项卡都相当于一个对话窗口容器,可以在其中独立地存放其他控件对象。 常用属性: ImageList属性:获取或设置当前TabControl控件中的各个标签页使用的图标集合。 MultiLine属性:获取或设置是否可以创建多行选项卡。 TabPages属性:获取该选项卡控件中选项卡页的集合。 6.9.1 选项卡控件(TabControl) 【例6-19】演示TabControl控件的用法。 设计界面 运行界面 6.9.2 面板复合控件 2、面板复合控件(SplitContainer) SplitContainer控件是由两个Panel面板和一个Split拆分条组成的复合体,两个Panel之间的拆分条可以拖动。 6.9.2 面板复合控件 【例6-20】演示SplitContainer控件的基本用法。 运行效果如下: 6.9.3 任务栏图标组件(NotifyIcon) 3、任务栏图标组件(NotifyIcon) NotifyIcon组件主要用于显示通知区域中的图标。NotifyIcon是一个比较特殊的组件,只有运行时才能显示。 常用属性: 【Icon】属性设置出现在状态区域的图标。 【Visible】属性控制是否让图标显示出来。 【Text】属性来指定将鼠标指针放置在图标上时显示的提示信息。 6.9.3 任务栏图标组件(NotifyIcon) 【例6-21】演示NotifyIcon控件的基本用法。 运行效果: 设计效果: 窗体的Load事件,在窗体显示前,执行该事件。 如何添加事件,在窗体设计界面显示时,在属性窗口点击Event图标,双击Load,即可在代码中添加事件原形。 Add some initialization code of your own. The last task is to add some initialization code of your own to Form1. The constructor should never be used to call any code that might throw an exception. Therefore, any such code must be located someplace else, and that location is the Form1_Load method. Click the Form1.cs[Design] tab at the top of the code editor to go back to Windows Form. Select the form and in the Properties window click the Events button (the one with the lightning bolt) and then double-click Load. This will add an event handler method and position your cursor in the method in Code view. When a user starts your program, Windows will notify your applications form by sending a Load event. When the form receives that event, it will call the Form1_Load method. Methods that are called in response to events are called event handlers. The system will call your event at the appropriate time; your job is to put the code into the event handler that you want to execute when the event occurs. 此例使用将篮球、排球、乒乓球三个复选框的CheckedChanged事件关联为下列方法:(在事件窗口中,选取三个复选框的事件处理程序为一个即可) 注意:froeach语句的用法 private void checkBoxGroup_CheckedChan
显示全部