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

首頁 > 開發 > 綜合 > 正文

改變 PropertyGrid 控件的編輯風格(3)——打開對話框

2024-07-21 02:24:07
字體:
來源:轉載
供稿:網友
菜鳥學堂:

改變 propertygrid 控件的編輯風格(3)——打開對話框

 

張昱[email protected] 效果:

適用場合:

1、   打開文件、打印設置等通用對話框

2、   打開特定的對話框

 

步驟一:定義從uitypeeditor 派生的類,以 openfiledialog 對話框為例,示例代碼如下:

using system;

using system.windows.forms;

using system.drawing.design;

using system.windows.forms.design;

 

namespace blog.csdn.net.zhangyuk

{

     /// <summary>

     /// imsopenfileinpropertygrid 的摘要說明。

     /// </summary>

     public class propertygridfileitem : uitypeeditor

     {

         public override uitypeeditoreditstyle geteditstyle(

system.componentmodel.itypedescriptorcontext context)

         {

              return uitypeeditoreditstyle.modal;

         }

        

         public override object editvalue(

system.componentmodel.itypedescriptorcontext context,

system.iserviceprovider provider,

object value)

         {           

              iwindowsformseditorservice edsvc = (iwindowsformseditorservice)

provider.getservice(typeof(iwindowsformseditorservice));

              if( edsvc != null )

              {

                   // 可以打開任何特定的對話框

                   openfiledialog dialog = new openfiledialog();

                   dialog.addextension = false;

                   if( dialog.showdialog().equals(dialogresult.ok) )

                   {

                       return dialog.filename;

                   }

              }

              return value;

         }

     }

}

 

步驟二:編輯屬性類,指定編輯屬性。示例如下:

namespace blog.csdn.net.zhangyuk

{

         public class someproperties

     {

         private string _finished_time   = "";

                   ……

         // 文件

         string _filename = "";

         [

              description("文件打開對話框"),

              category("屬性"),

            editorattribute(typeof(propertygridfileitem),

typeof(system.drawing.design.uitypeeditor))

         ]

         public string 文件

         {

              get { return _filename; }

              set { _filename = value;}

         }

         ……

         }

}

 

步驟三:設置propertygrid的屬性對象。示例如下:

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

         {

            this.propertygrid1.selectedobject = new someproperties();

         }

 

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 扶绥县| 乌兰县| 三门县| 丁青县| 九江县| 南郑县| 博兴县| 营口市| 重庆市| 廉江市| 库尔勒市| 德惠市| 东乌珠穆沁旗| 龙泉市| 鄂伦春自治旗| 邵阳市| 姚安县| 江达县| 洞头县| 榆林市| 绥德县| 依兰县| 合阳县| 新蔡县| 巴里| 武宁县| 新竹县| 临沧市| 呼伦贝尔市| 乌审旗| 玉门市| 乐亭县| 无极县| 岳普湖县| 响水县| 威宁| 志丹县| 牙克石市| 兴业县| 墨玉县| 枞阳县|