改变 PropertyGrid 控件的编辑风格(2)——编辑多行文本
适用场合:
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)——编辑多行文本相关推荐
- 使PropertyGrid控件的属性值可以显示多行的方法
第一步:重写UITypeEditor的GetEditStyle方法: 第二部:重写UITypeEditor的EditValue方法: 具体实现如下: 1 using System; 2 using S ...
- [转载]C# PropertyGrid控件应用心得
最近碰到关于PropertyGrid控件,以前没有使用过,在网上找了一篇不错的文章,转来分享一下!建议查看原文章! 原文链接:http://blog.csdn.net/luyifeiniu/artic ...
- c#中PropertyGrid 控件简介
PropertyGrid 控件简介 如果您使用过 Microsoft® Visual Basic® 或 Microsoft Visual Studio .NET,那么您一定使用过属性浏览器来浏览.查看 ...
- C# PropertyGrid 控件应用
C# PropertyGrid 控件应用 改文章转自:许海彪 原文链接:https://www.cnblogs.com/xuhaibiao/archive/2012/05/29/2524592.htm ...
- PropertyGrid控件 分类(Category)及属性(Property)排序
最近在做表单设计器,设计器上的控件都是我们自己封装的,但每个属性类别里的属性是按照属性的拼音排序的,现在想按照PropertyIndex标识进行排序(PropertyIndex的后三位是用来标识编辑器 ...
- WinForm窗体PropertyGrid控件使用
PropertyGrid控件是一个很全能的winform属性设置控件,可以将button,lab,text等控件的设置属性全部暴露出来.我这里简单介绍该控件的基本使用方法. 首先我这里定义了一个该控件 ...
- 判断手机是否弹出键盘,改变了手机页面高度,对应inputStatus的状态改变相关控件的大小和位置
inputResizeBodyHeight() {// 判断手机是否弹出键盘,改变了手机页面高度,对应inputStatus的状态改变相关控件的大小和位置var oldHeight =document ...
- WinForm窗体PropertyGrid控件的使用
使用过 Microsoft Visual Basic 或 Microsoft Visual Studio .NET的朋友,一定使用过属性浏览器来浏览.查看或编辑一个或多个对象的属性..NET 框架 P ...
- winform之propertyGrid控件简单使用方法
winform之propertyGrid控件简单使用方法 (一) winform之propertyGrid控件简单使用方法 常用的Attribute [CategoryAttribute(" ...
最新文章
- PAT甲级1121 Damn Single :[C++题解]哈希表、结构体
- Eclipse error: “The import XXX cannot be resolved”
- 代码检查规则背景及总体介绍
- JQuery插件:动态列和无间隙网格布局Mason.js
- 【编程好习惯】将常量放在“==”之前
- 作者:熊赟,博士,复旦大学计算机科学技术学院副教授。
- codeforces 848B Rooter's Song 思维题
- SIMIS计算机联锁系统,steam游戏sim
- Codeforces Round #483 (Div. 1) A. Finite or not?
- Linux下DNS服务器的基本搭建
- tag untag_交换机该怎么理解Hybird中Tag和Untag端口模式?
- Mysql/Oracle——常用SQL语句
- 07-figma-钢笔工具
- python解常微分方程龙格库_excel实现四阶龙格库塔法runge-kutta解二阶常微分方程范例.xls...
- C#程序开发范例宝典(第三版)(奋斗的小鸟)_PDF 电子书
- 时间序列-异常检测(Anomaly Detection)(二):传统方法
- 2022年11月编程语言排行
- 转:为什么谷歌越来越牛逼,而百度却...
- python 发红包import random用redenv_python 发红包
- GF(2^8)的加法与乘法计算