国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 開(kāi)發(fā) > 綜合 > 正文

改變 PropertyGrid 控件的編輯風(fēng)格(2)——編輯多行文本

2024-07-21 02:24:07
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

改變 propertygrid 控件的編輯風(fēng)格(2)——編輯多行文本

 

張昱[email protected] 效果:

適用場(chǎng)合:

1、   編輯多行文本;

2、   編輯長(zhǎng)文本。

 

步驟一:定義從uitypeeditor 派生的類(lèi),示例如下:

using system;

using system.windows.forms;

using system.drawing.design;

using system.windows.forms.design;

 

namespace blog.csdn.net.zhangyuk

{

     /// <summary>

     /// propertygridmutitext 的摘要說(shuō)明。

     /// </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;

         }

     }

}

 

步驟二:編輯屬性類(lèi),指定編輯屬性。示例如下:

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;}

         }

         ……

         }

}

 

步驟三:設(shè)置propertygrid的屬性對(duì)象。示例如下:

         private void form1_load(object sender, system.eventargs e)

         {

            this.propertygrid1.selectedobject = new someproperties();

         }

 

發(fā)表評(píng)論 共有條評(píng)論
用戶(hù)名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 探索| 左云县| 江油市| 丁青县| 晋中市| 大丰市| 玛多县| 台东市| 桦川县| 衡南县| 岳阳县| 临武县| 海伦市| 藁城市| 神池县| 朝阳区| 麟游县| 江川县| 星子县| 五台县| 漳浦县| 民权县| 正蓝旗| 灵川县| 土默特左旗| 九江县| 巧家县| 洛扎县| 乌鲁木齐县| 汉沽区| 邹城市| 四会市| 九龙坡区| 洛隆县| 桐柏县| 临朐县| 渝北区| 闵行区| 汤阴县| 札达县| 武功县|