改变 propertygrid 控件的编辑风格(2)——编辑多行文本
2007-09-29 09:43
513 查看
适用场合:
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();
}
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();
}
相关文章推荐
- 改变 PropertyGrid 控件的编辑风格(2)——编辑多行文本
- 改变 PropertyGrid 控件的编辑风格(3)——打开对话框
- 改变 PropertyGrid 控件的编辑风格(4)——加入选择列表
- 改变 PropertyGrid 控件的编辑风格(1)——加入日期控件-.NET教程,组件控件开发
- 改变 propertygrid 控件的编辑风格(3)——打开对话框
- 改变 propertygrid 控件的编辑风格(4)——加入选择列表
- 改变 PropertyGrid 控件的编辑风格(1)——加入日期控件
- c#.net 文本编辑控件——C# RichTextBox对象中插入文字而不改变文本格式
- c#.net 文本编辑控件——C# RichTextBox对象中插入文字而不改变文本格式
- 改变PropertyGrid编辑风格(转)
- 横秋扫盲系列(4): CRichEditCtrl 超文本编辑(MSN/QQ常用控件) -- 2005-08-28 21:13:15
- 文本编辑控件. 谢谢大家支持,后续即将发布
- VC改变控件的背景颜色 字体 文本颜色
- 不可编辑的文本控件TextView
- 【python cookbook】改变多行文本字符串的缩进
- 让CStatic控件根据自己的需要改变,文本,文本颜色,填充背景色
- RDIFramework.NET ━ .NET快速信息化系统开发框架 V3.2->Web版本“产品管理”事例编辑界面新增KindEditor复文本编辑控件
- MFC中改变静态文本控件字体字号和颜色的方法
- C++ Win32项目STATIC TEXT 控件中响应点击,并改变文本颜色
- 【Visual Studio风格开发系列 - PropertyGrid控件】C# 充分利用 .NET 框架的 PropertyGrid 控件