zoukankan      html  css  js  c++  java
  • ComboBox中Tag的使用,转换为Enum类型

    private ClientMessageObject CreateNewMessage() {
       ClientMessageObject cmsg = new ClientMessageObject();
       RtfFilter filter = new RtfFilter();
       String contentText = filter.ConvertFromDocument(this.rtbContent.Document);
       int[] receiverUserIds = (int[])this.txtRecipient.Tag;
       String recipientName = this.txtRecipient.Text;
       String strReceiverUserIds = WfMessageContent.IntArrayToString(",", receiverUserIds);
       cmsg.Content = this.GetContent(contentText, recipientName, strReceiverUserIds);

    //Tag的引用,转换为Enum类型:
       cmsg.Priority =(WfPriority)((ComboBoxItem)this.ucePriority.SelectedItem).Tag;
       cmsg.SentDateTime = DateTime.Now;
       cmsg.Sid = new Guid();
       cmsg.SourceType = MessageSourceTypes.User;
       cmsg.Subject = this.txtSubject.Text;
       cmsg.UnRead = false;
       IUser user = (IUser)this._recipient;
       if (user != null) {
        cmsg.UserId = user.UserID;
        cmsg.UserName = recipientName;
       } else {
        if (this._clientMessage != null) {
         cmsg.UserId = this._clientMessage.UserId;
         cmsg.UserName = this._clientMessage.UserName;
        }
       }
       cmsg.WorkOrderNum = "";

       return cmsg;
      }

    private void InitializeUcePriority() {
       Type type = typeof(WfPriority);
       foreach (FieldInfo fieldInfo in type.GetFields(BindingFlags.Static | BindingFlags.Public)) {
        ComboBoxItem item = new ComboBoxItem();
        item.Content = this.GetWfPriorityDisplayTextFromResx(fieldInfo.Name);

    //定义Tag
        item.Tag = (Int32)(WfPriority)fieldInfo.GetValue(type);
        this.ucePriority.Items.Add(item);
       }
       this.ucePriority.SelectedIndex = 2;
      }

    #region Localization
      private string GetWfPriorityDisplayTextFromResx(String priority) {
       switch (priority.ToLower()) {
        case "highest":
         return BoxPropertyCollectionResx.highest;
        case "high":
         return BoxPropertyCollectionResx.high;
        case "normal":
         return BoxPropertyCollectionResx.normal;
        case "low":
         return BoxPropertyCollectionResx.low;
        case "lowest":
         return BoxPropertyCollectionResx.lowest;
        default:
         return string.Empty;
       }
      }
      #endregion

  • 相关阅读:
    烂泥:mysql修改本地主机连接
    烂泥:ESXI开启SNMP服务
    烂泥:【解决】VMware Workstation中安装ESXI5.0双网卡问题
    JS-日历签到
    CSS-文本(中,英)
    js-无缝向上滚动
    js-键盘回车搜索enter
    小程序-初次进入小程序的授权问题(授权更新后的完整步骤)button主动授权
    字蛛(font-spider)-单独压缩字体(解决页面少有的特殊字体的字体包引用)
    js-利用插件qrcode.min.js,前端实时生成二维码
  • 原文地址:https://www.cnblogs.com/stragon/p/1640884.html
Copyright © 2011-2022 走看看