.NET开发

本类阅读TOP10

·vs.net 2005中文版下载地址收藏
·NHibernate快速指南(翻译)
·【小技巧】一个判断session是否过期的小技巧
·通过Web Services上传和下载文件
·?dos下编译.net程序找不到csc.exe文件
·VB/ASP 调用 SQL Server 的存储过程
·学习笔记(补)《.NET框架程序设计(修订版)》--目录
·对比.NET PetShop和Duwamish来探讨Ado.NET的数据库编程模式
·Autodesk官方最新的.NET教程(一)(vb.net版)
·Duwamish深入剖析-结构篇

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
PropertyGrid 用法(下拉框篇)

作者:未知 来源:月光软件站 加入时间:2005-5-13 月光软件站

如果有在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;}
  }

}




相关文章

相关软件




月光软件程序下载编程文档电脑教程网站设计网址导航网络文学游戏天地幽默笑话生活休闲写作范文安妮宝贝
电脑技术编程开发网络专区谈天说地情感世界游戏元素分类游戏热门游戏体育运动手机专区业余爱好影视沙龙
音乐天地数码广场教育园地科学大观古今纵横谈股论金人文艺术医学保健动漫图酷二手专区地方风情各行各业

月光软件站·版权所有