中国IT动力,最新最全的IT技术教程
最新100篇 | 推荐100篇 | 专题100篇 | 排行榜 | 搜索 | 在线API文档 | 网通镜像
首 页 | 程序开发 | 操作系统 | 软件应用 | 图形图象 | 网络应用 | 精文荟萃 | 教育认证 | 硬件维护 | 未整理篇 | 站长教程
ASP JS PHP工程 ASP.NET 网站建设 UML J2EESUN .NET VC VB VFP 网络维护 数据库 DB2 SQL2000 Oracle Mysql
服务器 Win2000 Office C DreamWeaver FireWorks Flash PhotoShop 上网宝典 CorelDraw 协议大全 网络安全 微软认证
硬件维护  CPU  主板  硬盘  内存  显卡  显示器  键盘鼠标  声卡音箱  打印机  机箱电源  BIOS  网卡  C#  Java  Delphi  vs.net2005
  当前位置:> 程序开发 > 编程语言 > .NET > 临时文章
PropertyGrid 用法(下拉框篇)
作者:未知 时间:2005-03-12 12:12 出处:Blog 责编:chinaitpower
              摘要:暂无

如果有在PropertyGrid中用下拉框的朋友有困难的,请参见下面。并希望高手提出意见,

说明:下面的代码是不能run的。这是直接copy了我的东西,想用的朋友,需要修一些地方.

using System;
using System.Text;
using System.Reflection;
using System.Collections;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Data;
using System.Drawing;
using System.Drawing.Design;

namespace Com.WorkFlowEnginer.Entity
{
 #region 对象下来列表控建[Role]
 
 //对象选择下拉列表转化
 public class DropDownListRoleConverter : System.Drawing.Design.UITypeEditor
 {
  public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
  {
   return System.Drawing.Design.UITypeEditorEditStyle.DropDown;
  }

  public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
  {
   System.Windows.Forms.Design.IWindowsFormsEditorService iws = (System.Windows.Forms.Design.IWindowsFormsEditorService)provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService));
   if(iws!=null)
   {
    DropDownListRoleControll dlc = new DropDownListRoleControll(iws);
    iws.DropDownControl(dlc);
    return dlc.SelectString;
   }
   return value;
  }
 }
 
 public class DropDownListRoleControll : System.Windows.Forms.ListBox
 {
  public DropDownListRoleControll(System.Windows.Forms.Design.IWindowsFormsEditorService iws)
  {
   //初始化下拉列表 此处需要修改

   DataTable dt = Com.WorkFlowEnginer.RoleManager.GetRoleList();
   if ( dt != null && dt.Rows.Count>0)
   {
    foreach(DataRow dr in dt.Rows)
    {
     Role role = new Role();
     role.RoleGuid = dr["Guid"].ToString();
     role.Name = dr["Name"].ToString();
     this.Items.Add(role);
    }
   }
   
   this._iws = iws;
   this.Visible = true;
   this.Height =100;
   this.BorderStyle = System.Windows.Forms.BorderStyle.None;
   //添加事件
   this.SelectedValueChanged +=new EventHandler(cb_SelectedValueChanged);
   
  }

//此处可以修改

  private Com.WorkFlowEnginer.Entity.Role select = null;
  public Com.WorkFlowEnginer.Entity.Role SelectString
  {
   get
   {
    return this.select;
   }
   
  }
  private System.Windows.Forms.Design.IWindowsFormsEditorService _iws;

  private void cb_SelectedValueChanged(object sender, EventArgs e)
  {
   if ( this.SelectedItem != null)
   {

 //此处需要修改
    this.select = (Com.WorkFlowEnginer.Entity.Role)this.SelectedItem;
    this._iws.CloseDropDown();
   }
   else
    System.Windows.Forms.MessageBox.Show("无对象可得","提示",System.Windows.Forms.MessageBoxButtons.OK,System.Windows.Forms.MessageBoxIcon.Error);
  }
 }
 #endregion

public class Activity

{

[
  CategoryAttribute("活动属性"),
  ReadOnlyAttribute(false),
  BrowsableAttribute(true),
  EditorAttribute(typeof(DropDownListRoleConverter),typeof(System.Drawing.Design.UITypeEditor)),
  DescriptionAttribute("流程中所需要的角色的名称."),
  showChinese("角色名称:")
  ]

//此处需要修改
  public Role Role
  {
   get { return role;}
   set { role = value;}
  }

}

关闭本页
 
首页 | 投资与合作 | 服务条款 | 隐私政策 | 收藏本站 | 设为首页 | 新用户注册 | 免责声明 | 使用帮助
Copyright ©2005-2008 chinaitpower.com All rights reserved. www.chinaitpower.com 版权所有