首页 > 编程 > .NET > 正文

充分利用 .NET 框架的 PropertyGrid 控件(微软)之三

2024-07-10 13:03:59
字体:
来源:转载
供稿:网友
  • 网站运营seo文章大全
  • 提供全面的站长运营经验及seo技术!
  • 何处使用 propertygrid 控件
    在应用程序中的很多地方,您都可以使用户与 propertygrid 进行交互,从而获得更丰富的编辑体验。例如,某个应用程序包含多个用户可以设置的“设置”或选项,其中一些可能十分复杂。您可以使用单选按钮、组合框或文本框来表示这些选项。但本文将逐步介绍如何使用 propertygrid 控件创建选项窗口来设置应用程序选项。上面所创建的 optionsdialog 窗体即是选项窗口的开始。现在,我们创建一个名为 appsettings 的类,其中包含映射到应用程序设置的所有属性。如果创建单独的类而不使用多个分散的变量,设置将更便于管理和维护。

    ' visual basic

    public class appsettings
        private _saveonclose as boolean = true
        private _greetingtext as string = "欢迎使用应用程序!"
        private _maxrepeatrate as integer = 10
        private _itemsinmru as integer = 4

        private _settingschanged as boolean = false
        private _appversion as string = "1.0"

        public property saveonclose() as boolean
            get
                return _saveonclose
            end get
            set(byval value as boolean)
                saveonclose = value
            end set
        end property

        public property greetingtext() as string
            get
                return _greetingtext
            end get
            set(byval value as string)
                _greetingtext = value
            end set
        end property

        public property itemsinmrulist() as integer
            get
                return _itemsinmru
            end get
            set(byval value as integer)
                _itemsinmru = value
            end set
        end property

        public property maxrepeatrate() as integer
            get
                return _maxrepeatrate
            end get
            set(byval value as integer)
                _maxrepeatrate = value
            end set
        end property

        public property settingschanged() as boolean
            get
                return _settingschanged
            end get
            set(byval value as boolean)
                _settingschanged = value
            end set
        end property

        public property appversion() as string
            get
                return _appversion
            end get
            set(byval value as string)
                _appversion = value
            end set
        end property
    end class


    发表评论 共有条评论
    用户名: 密码:
    验证码: 匿名发表