设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

返回列表 发新帖
查看: 7131|回复: 0
打印 上一主题 下一主题

【作业】04课-紫电

[复制链接]
跳转到指定楼层
1#
发表于 2014-3-23 17:50:23 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 紫电 于 2014-3-28 23:08 编辑

1、稍后添加,防止晚上发帖要审核。
二、DropDown、ComboBox、SplitButton用法详解。
1、DropDown:表示用户可以从中进行选择的项列表和用户可以单击的功能区按钮列表。
用法:
RibbonDropDown 可以包含 RibbonDropDownItem 对象和 RibbonButton 控件。
在运行时,可以使用 RibbonFactory 对象的 CreateRibbonDropDown 方法创建 RibbonDropDown。
有两种方法可访问 RibbonFactory 对象:
  • 使用功能区类的 Factory 属性。 请通过功能区类中的代码使用此方法。
  • 使用 Globals.Factory.GetRibbonFactory 方法。 请通过功能区类之外的代码使用此方法。
在功能区加载到 Office 之后,您不能在运行时向 Buttons 集合中添加按钮。
注意点:
(1)、上面就是说不能添加RibbonButton,运行时是可以添加RibbonDropDownItem的。
(2)、在Ribbon设计器中,就这么写: this.Factory
在其他地方就这么写:RibbonFactory MyFactory = Globals.Factory.GetRibbonFactory();
Excel用法举例:
点一下,如果是item,就会改变表面的字;按钮只能是设计模式的时候添加,所以这货不好使,很用用到它。找了许久只找到一个,如下
BorderStyle
线型
dropDown
代码实例:
  1.         private void dropYY_ItemsLoading(object sender, RibbonControlEventArgs e)
  2.         {
  3.             dropYY.Items.Clear();
  4.             foreach (KeyValuePair<string, RibbonDropDownItem> Item in m_RunMyControl.GetControls())
  5.             {
  6.                 dropYY.Items.Add(Item.Value);
  7.             }
  8.         }
复制代码
2、ComboBox:表示自定义功能区上的组合框。
用法:
组合框在下拉菜单中为用户提供了一个文本输入字段和一个选项列表。
在运行时,可以使用 RibbonFactory 对象的 CreateRibbonComboBox 方法创建 RibbonComboBox。
有两种方法可访问 RibbonFactory 对象:
  • 使用功能区类的 Factory 属性。 请通过功能区类中的代码使用此方法。
  • 使用 Globals.Factory.GetRibbonFactory 方法。 请通过功能区类之外的代码使用此方法。
此类型的某些成员只能在功能区加载到 Office 应用程序之前设置。
注意点:
这货只能使用RibbonDropDownItem,选中了,就改变了文本框中的字符,字符也可以手动打进去。

Excel用法举例:Excel中还挺多的,鼠标点下框,能打字的带下拉箭头的,都是它!

代码实例:
  1.         #region 第三种实现方法,支持手动输入频道号、房间号
  2.         //房间号
  3.         private void cmbYY_TextChanged(object sender, RibbonControlEventArgs e)
  4.         {
  5.             string RoomID = "";
  6.             if (m_CmbItems.ContainsKey(cmbYY.Text))
  7.             {
  8.                 //存在此房间
  9.                 RoomID = m_CmbItems[cmbYY.Text].Tag.ToString();
  10.                 cmbYY.SuperTip = "您选择的房间号为:" + RoomID;//显示房间号
  11.                 editYY.Text = m_RunMyControl.DefalutChannel.Value;//重置频道号
  12.                 editYY.SuperTip = "您选择的频道号为:" + m_RunMyControl.DefalutChannel.Key;
  13.                 m_RunMyControl.EnterYYRoom(RoomID);
  14.             }
  15.             else if ("" == cmbYY.Text)
  16.             {
  17.                 return;//不能为空,退出,等待输入数据
  18.             }
  19.             else if (! m_RunMyControl.IsNumeric(cmbYY.Text))
  20.             {
  21.                 //不能为非数字的字符
  22.                 cmbYY.Text="";
  23.                 cmbYY.SuperTip = "";
  24.                 System.Windows.Forms.MessageBox.Show("不能输入非数字的频道号!");
  25.                 return;
  26.             }
  27.             else
  28.             {
  29.                 //检测频道号
  30.                 if (m_RunMyControl.DefalutChannel.Value == editYY.Text || "" == editYY.Text)
  31.                 {
  32.                     //自定义打开YY时,不允许使用默认的频道号
  33.                     editYY.Text = "";
  34.                     editYY.SuperTip = "";
  35.                     cmbYY.SuperTip = "";
  36.                     System.Windows.Forms.MessageBox.Show("请输入频道号");
  37.                 }
  38.                 else
  39.                 {
  40.                     //一切正常,打开YY
  41.                     RoomID = cmbYY.Text;
  42.                     cmbYY.SuperTip = "您选择的房间号为:" + RoomID;//显示房间号
  43.                     m_RunMyControl.EnterYYRoom(RoomID,editYY.Text);
  44.                 }
  45.             }                        
  46.         }

  47.         //频道号
  48.         private void editYY_TextChanged(object sender, RibbonControlEventArgs e)
  49.         {
  50.             if ("" == editYY.Text )
  51.             {
  52.                 return;//频道号不能为空,退出等待输入!
  53.             }
  54.             else if (! m_RunMyControl.IsNumeric(editYY.Text))
  55.             {
  56.                 //不能为非数字的字符
  57.                 editYY.Text = "";
  58.                 editYY.SuperTip = "";
  59.                 System.Windows.Forms.MessageBox.Show("不能输入非数字的频道号!");
  60.                 return;
  61.             }
  62.             else if (m_CmbItems.ContainsKey(cmbYY.Text) || "" == cmbYY.Text)
  63.             {
  64.                 //自定义打开YY时,不允许使用现有的频道号,房间号不允许为空
  65.                 cmbYY.Text = "";
  66.                 cmbYY.SuperTip = "";
  67.                 editYY.SuperTip = "";
  68.                 System.Windows.Forms.MessageBox.Show("请输入房间号");
  69.             }
  70.             else
  71.             {
  72.                 //一切正常,打开YY
  73.                 m_RunMyControl.EnterYYRoom(cmbYY.Text, editYY.Text);
  74.             }
  75.         }
  76.         #endregion
复制代码












本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖 订阅订阅
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-4-20 03:29 , Processed in 0.089930 second(s), 25 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表