国产探花免费观看_亚洲丰满少妇自慰呻吟_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();

         }

 

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 昌乐县| 旌德县| 房山区| 册亨县| 青龙| 新巴尔虎左旗| 澄江县| 诸城市| 平和县| 建始县| 博罗县| 沂南县| 屏南县| 西林县| 青神县| 光山县| 长兴县| 柳林县| 达尔| 蒙阴县| 宁蒗| 康乐县| 邵武市| 绥宁县| 凉山| 池州市| 云霄县| 永仁县| 故城县| 监利县| 合阳县| 共和县| 顺平县| 吴川市| 盐城市| 宜君县| 建昌县| 武义县| 方正县| 望奎县| 建昌县|