适用场合:
  1、 编辑多行文本;
  2、 编辑长文本。
  步骤一:定义从UITypeEditor 派生的类,示例如下:
  using System;
  using System.Windows.Forms;
  using System.Drawing.Design;
  using System.Windows.Forms.Design;
  namespace blog.csdn.net.zhangyuk
  {
   /// <summary>
   /// PropertyGridMutiText 的摘要说明。
   /// </summary>
   public class PropertyGridRichText : UITypeEditor
   {
   public override UITypeEditorEditStyle GetEditStyle(
  System.ComponentModel.ITypeDescriptorContext context)
   {
   return UITypeEditorEditStyle.DropDown;
   }
  
   public override object EditValue(
  System.ComponentModel.ITypeDescriptorContext context,
  System.IServiceProvider provider,
  object value)
   {
   try
   {
   IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)
  provider.GetService(typeof(IWindowsFormsEditorService));
   if( edSvc != null )
   {
   if( value is string )
   {
   RichTextBox box = new RichTextBox();
   box.Text = value as string;
   edSvc.DropDownControl( box );
   return box.Text;
   }
   }
   }
   catch( Exception ex )
   {
   System.Console.WriteLine( 'PropertyGridRichText Error : ' + ex.Message );
   return value;
   }
   return value;
   }
   }
  }
  步骤二:编辑属性类,指定编辑属性。示例如下:
  namespace blog.csdn.net.zhangyuk
  {
   public class SomeProperties
   {
   private string _finished_time = '';
   ……
   // 多行文本编辑框
   string _mutiLineSample = '';
   [
   Description('多行文本编辑框'),
   Category('属性'),
   EditorAttribute(typeof(PropertyGridRichText),
  typeof(System.Drawing.Design.UITypeEditor))
   ]
   ]
   public String 多行文本
   {
   get { return _mutiLineSample; }
   set { _mutiLineSample = value;}
   }
   ……
   }
  }
  步骤三:设置PropertyGrid的属性对象。示例如下:
   private void Form1_Load(object sender, System.EventArgs e)
   {
   this.propertyGrid1.SelectedObject = new SomeProperties();
   }

转载于:https://www.cnblogs.com/worfdream/articles/1898827.html

改变 PropertyGrid 控件的编辑风格(2)——编辑多行文本相关推荐

  1. 使PropertyGrid控件的属性值可以显示多行的方法

    第一步:重写UITypeEditor的GetEditStyle方法: 第二部:重写UITypeEditor的EditValue方法: 具体实现如下: 1 using System; 2 using S ...

  2. [转载]C# PropertyGrid控件应用心得

    最近碰到关于PropertyGrid控件,以前没有使用过,在网上找了一篇不错的文章,转来分享一下!建议查看原文章! 原文链接:http://blog.csdn.net/luyifeiniu/artic ...

  3. c#中PropertyGrid 控件简介

    PropertyGrid 控件简介 如果您使用过 Microsoft® Visual Basic® 或 Microsoft Visual Studio .NET,那么您一定使用过属性浏览器来浏览.查看 ...

  4. C# PropertyGrid 控件应用

    C# PropertyGrid 控件应用 改文章转自:许海彪 原文链接:https://www.cnblogs.com/xuhaibiao/archive/2012/05/29/2524592.htm ...

  5. PropertyGrid控件 分类(Category)及属性(Property)排序

    最近在做表单设计器,设计器上的控件都是我们自己封装的,但每个属性类别里的属性是按照属性的拼音排序的,现在想按照PropertyIndex标识进行排序(PropertyIndex的后三位是用来标识编辑器 ...

  6. WinForm窗体PropertyGrid控件使用

    PropertyGrid控件是一个很全能的winform属性设置控件,可以将button,lab,text等控件的设置属性全部暴露出来.我这里简单介绍该控件的基本使用方法. 首先我这里定义了一个该控件 ...

  7. 判断手机是否弹出键盘,改变了手机页面高度,对应inputStatus的状态改变相关控件的大小和位置

    inputResizeBodyHeight() {// 判断手机是否弹出键盘,改变了手机页面高度,对应inputStatus的状态改变相关控件的大小和位置var oldHeight =document ...

  8. WinForm窗体PropertyGrid控件的使用

    使用过 Microsoft Visual Basic 或 Microsoft Visual Studio .NET的朋友,一定使用过属性浏览器来浏览.查看或编辑一个或多个对象的属性..NET 框架 P ...

  9. winform之propertyGrid控件简单使用方法

    winform之propertyGrid控件简单使用方法 (一) winform之propertyGrid控件简单使用方法 常用的Attribute [CategoryAttribute(" ...

最新文章

  1. PAT甲级1121 Damn Single :[C++题解]哈希表、结构体
  2. Eclipse error: “The import XXX cannot be resolved”
  3. 代码检查规则背景及总体介绍
  4. JQuery插件:动态列和无间隙网格布局Mason.js
  5. 【编程好习惯】将常量放在“==”之前
  6. 作者:熊赟,博士,复旦大学计算机科学技术学院副教授。
  7. codeforces 848B Rooter's Song 思维题
  8. SIMIS计算机联锁系统,steam游戏sim
  9. Codeforces Round #483 (Div. 1) A. Finite or not?
  10. Linux下DNS服务器的基本搭建
  11. tag untag_交换机该怎么理解Hybird中Tag和Untag端口模式?
  12. Mysql/Oracle——常用SQL语句
  13. 07-figma-钢笔工具
  14. python解常微分方程龙格库_excel实现四阶龙格库塔法runge-kutta解二阶常微分方程范例.xls...
  15. C#程序开发范例宝典(第三版)(奋斗的小鸟)_PDF 电子书
  16. 时间序列-异常检测(Anomaly Detection)(二):传统方法
  17. 2022年11月编程语言排行
  18. 转:为什么谷歌越来越牛逼,而百度却...
  19. python 发红包import random用redenv_python 发红包
  20. GF(2^8)的加法与乘法计算

热门文章

  1. [小改进]Blog页面导航调整
  2. haproxy对mysql集群进行负载均衡
  3. 【leetcode】1032. Stream of Characters
  4. 小论Java类变量的隐私泄露
  5. 小组结队项目-四则运算
  6. Elasticsearch上手——熟悉基本操作
  7. 线程池设计中的惊群问题
  8. 怎样把android应用部署到手机上
  9. wpservice.exe应用程序错误
  10. CN.Text开发笔记—利用反射将数据读入实体类